+17 votes
2 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

+24 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
+9 votes
by (570 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.

+9 votes
by (92.8k 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: 

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...