Difference between createOrReplaceTempView and registerTempTable (or) createOrReplaceTempView vs registerTempTable.

All the functions mentioned below are more or less same functionally, but there very minor differences among them.

  • createOrReplaceTempView
  • createTempView
  • registerTempTable

The function registerTempTable is added from 1.3 version of Spark whereas the other two are added in the version 2.0. So registerTempTable is deprecated from Spark 2.0 onwards.

The life span of the view created by registerTempTable is limited to the SqlContext that was used to create the dataframe, whereas the life time of the view created by createOrReplaceTempView will be tied to SparkSession that was used to create the dataframe.

 

Please provide your feedback of this post..

Leave a Reply

Your email address will not be published. Required fields are marked *