Is it possible to export the output of a "magic SQL" command cell in Databricks?
I like the fact that one doesn't have to escape the SQL command and it can be easily formatted. But, I cant seem to be able to use the output in other cells. What I would like to do is export the data to a CSV file, but potentially, finish some final manipulation of the dataframe before I write it out.
sql = "select * from calendar"
df = sqlContext.sql(sql)
display(df.limit(10))
vs (DBricks formatted the following code)
%sql
select
*
from
calendar
but imagine, once you bring in escaped strings, nested joins, etc. Wondering if there is a better way to work with SQL in databricks.