Back

Explore Courses Blog Tutorials Interview Questions
+15 votes
5 views
in Big Data Hadoop & Spark by (330 points)

I am a newbie in spark and trying to find out some commands in sparksql while using python. Can anyone tell what is the main difference between these two commands :
createOrReplaceTempView() Vs registerTempTable(). Their functionalities seem to be the same.

3 Answers

+22 votes
by (13.2k points)
edited by
createOrReplaceTempView and registerTempTable both performs the same function.

createOrReplaceTempView was introduced as a replacement for registerTempTable in Spark 2.0
+8 votes
by (550 points)
edited by

Hi @kavita as @Shivangi said the functionalities of both the methods are same.

If you open this https://spark.apache.org/docs/2.0.0/api/python/pyspark.sql.html

do ctrl+f and

type registerTempTable then you will see it is depreciated in 2.0 and use createOrReplaceTempView instead.

+8 votes
by (108k points)
edited by

createOrReplaceTempView() creates/replaces a local temp view with the dataframe provided. A lifetime of this view is dependent on SparkSession class, if you want to drop this view :

spark.catalog.dropTempView("name")

createGlobalTempView() creates a global temporary view with the dataframe provided. A lifetime of this view is dependent to spark application itself. If you want to drop :

spark.catalog.dropGlobalTempView("name")

For more information regarding the same, refer the following video: 

Browse Categories

...