Hi Gaurav
I am not sure what you are trying to do here as you are naming two data frames
with the same name which would be a compilation error in java.
However, after trying to see what you are asking, as of what I understand your
question is.
You can do something like this;
> SqlContext sqlContext = new SQlContext(sc) // This will create a sqlcontext
> object to leverage spark-sql api.
DataFrame firstDataFrame =
sqlContext.read().jdbc(“url”,”(select * from employee) as emp”) // See here I
am throwing a sub query to select all the employee
/* Or I can also have a subquery like this "(select * from
employee as e where e.empid = 1) as emp". The subquery that you throw as a part
of
* parameters would be running inside the database that you are
connecting to using the url specified in the query.
DataFrame secondDataFrame =
sqlContext.read().jdbc(“url”,”(select * from department as d where d.deptid =
2) as dept”)
firstDataFrame.show();
secondDataFrame.show();
Please tell me if I cleared you query or I didn’t then please clarify your
question. Please ask me if you have any other question too.
Thanks
Regards
Rishabh Wadhawan
> On Feb 11, 2016, at 9:47 AM, Gaurav Agarwal <[email protected]> wrote:
>
> SqlContext sContext = new SQlContext(sc)
> DataFrame df = sContext.load("jdbc","select * from employee"); // These
> queries will be the Map<String,String> with driver.
> DataFrame df = sContext.load("jdbc","select * from Dept");