What's the difference between a Global view and a Temp view?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2021 03:39 PM
The difference between Global and Temp is how the lifetime of the view is tied to the application:
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.
Creates or replaces a global temporary view using the given name.
The lifetime of this temporary view is tied to this Spark application.
- Labels:
-
Global Temporary View
-
Tempview
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2021 09:11 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2024 06:27 PM
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

