I have to query multiple sql queries, and in some case one 2nd sql query is dependent on the results from first query (results returned are used in the where clause). What should be my approach?
- Should i save my first query results in a tempview and loop it around to get access to the 2nd results, create the sql, execute it. And follow the same with next row data from tempview.
- I have created a runquery function , but do i need to every time also mention connection details. (like driver, url, user, password… etc). How can i make a common connection function.
- I am using df.select(“xyz”).collect()(0) to access the first row+column result. What are the other ways to access the rows and loop through them.
Can any one help with a sample code piece.
Thanks in Advance