Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between createOrReplaceGlobalTempView and createOrReplaceTempView

I am trying to understand the difference between createOrReplaceGlobalTempView and createOrReplaceTempView.

createOrReplaceTempView is introduced in version 2.0 and createOrReplaceGlobalTempView is introduced in 2.2.

As per the documentation,

for createOrReplaceGlobalTempView : the lifetime of this temporary view is tied to this Spark application.

For createOrReplaceGlobalTempView : The lifetime of this temporary table is tied to the SparkSession that was used to create this DataFrame.

Could you please elaborate the difference on Spark Application and SparkSession.

Regards,

Neeraj

like image 422
Neeraj Bhadani Avatar asked Jan 30 '18 10:01

Neeraj Bhadani


Video Answer


1 Answers

Standard temporary tables live in the user space, similarly to Hive

The data in these tables is stored in the user's scratch directory rather than in the Hive warehouse directory. The scratch directory effectively acts as the user' data sandbox.

and are limited to a single user session.

Global temporary views, are different, in the way that can be accessed by multiple sessions, so there are intermediate between normal view (it can be accessed globally, it is registered in global temporary database) and temporary view (its scope is limited to a single session).

like image 59
Alper t. Turker Avatar answered Oct 14 '22 04:10

Alper t. Turker