How can I convert a pyspark.sql.dataframe.DataFrame back to a sql table in databricks notebook How can I convert a pyspark.sql.dataframe.DataFrame back to a sql table in databricks notebook sql sql

How can I convert a pyspark.sql.dataframe.DataFrame back to a sql table in databricks notebook


You can create your table by using createReplaceTempView. In your case it would be like:

dataframe.createOrReplaceTempView("mytable")

After this you can query your mytable using SQL.

If your a spark version is ≤ 1.6.2 you can use registerTempTable