I have a sql query results that I would like to convert into a pandas df within the databricks notebook. The query is pulling data from the dbx tables, if this is important to know.
My query looks something like this:
With cte1 as (
SELECT col1, col2 FROM Table1),
cte2 as(
SELECT col10, col12 FROM Table2)
SELECT * FROM cte1 JOIN cte2 on col1=col10
I got the results that I am looking for, then I want to convert this into a pandas df while within databricks.
The last one I tried is using the from pyspark.sql import SQLContext after my last googling, though there is nothing specific to my intention that I can find, but it throws a sql error.
from pyspark.sql import SQLContext
sqlContext = SQLContext(sc)
df = sqlContext.sql("""
With cte1 as (
SELECT col1, col2 FROM Table1),
cte2 as(
SELECT col10, col12 FROM Table2)
SELECT * FROM cte1 JOIN cte2 on col1=col10
"""
)
Is there a way to convert the sql query results into a pandas df within databricks notebook?