0

Is there a way to include dataframes inside a sql query? I'm actually trying to break a huge sql query and put in multiple dataframes and call those dataframes inside the original query.

select * from DF alike?

1 Answer 1

3

You can create a Temporary View using Dataframe which can be used in Spark Sql

For e.g. If you have Dataframe 'df' then you can run this to create temporary View with any name e.g. "my_table"

df.createOrReplaceTempView("my_table")

Now you can run query on top of this using following to load this as newer dataframe:

df2 = spark.sql("select * from my_table")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.