Explore Courses Blog Tutorials Interview Questions
+15 votes
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

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 :


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 :


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

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

29.3k questions

30.6k answers


104k users

Browse Categories