cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

What's the difference between a Global view and a Temp view?

User15787040559
Databricks Employee
Databricks Employee

The difference between Global and Temp is how the lifetime of the view is tied to the application:

http://spark.apache.org/docs/latest/api/python/reference/api/pyspark.sql.DataFrame.createOrReplaceTe...

Creates or replaces a local temporary view with this DataFrame.

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

http://spark.apache.org/docs/latest/api/python/reference/api/pyspark.sql.DataFrame.createOrReplaceGl...

Creates or replaces a global temporary view using the given name.

The lifetime of this temporary view is tied to this Spark application.

2 REPLIES 2

aladda
Databricks Employee
Databricks Employee

In the context of Databricks Notebooks and Clusters

  • A Temp View is available across the context of a Notebook and is a common way of sharing data across various language REPL - Ex:- Python to Scala.
  • A Global Temp View is available to all Notebooks running on that Databricks Cluster

ScottSmithDB
Databricks Employee
Databricks Employee

Correct A Temp View is scoped to the SparkSession and dropped when that session closes.  Each notebook runs in its own SparkSession.  The Global Temp View is scoped to the cluster and dropped when the cluster re-starts or you drop it.

----------------------------------------------------------------------

TEMPORARY

TEMPORARY views are visible only to the session that created them and are dropped when the session ends.

GLOBAL TEMPORARY

Applies to: check marked yes Databricks Runtime

GLOBAL TEMPORARY views are tied to a system preserved temporary schema global_temp.

https://docs.databricks.com/en/sql/language-manual/sql-ref-syntax-ddl-create-view.html

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group