Command
spark.sql()Explanation
Register DataFrame as temp view and run SQL queries.
Examples
Register DataFrame as SQL table
df.createOrReplaceTempView("people")Run SQL query
spark.sql("SELECT * FROM people WHERE age > 25").show()spark.sql()Register DataFrame as temp view and run SQL queries.
Register DataFrame as SQL table
df.createOrReplaceTempView("people")Run SQL query
spark.sql("SELECT * FROM people WHERE age > 25").show()