Skip to content

GlobalTempViewManager -- Management Interface of Global Temporary Views

GlobalTempViewManager is the <> to manage global temporary views (that SessionCatalog uses when requested to create, alter or drop global temporary views).

Strictly speaking, GlobalTempViewManager simply <> the names of the global temporary views registered (and the corresponding <>) and has no interaction with other services in Spark SQL.

GlobalTempViewManager is available as SharedState.md#globalTempViewManager[globalTempViewManager] property of a SharedState.

.GlobalTempViewManager and SparkSession image::images/spark-sql-GlobalTempViewManager.png[align="center"]

[source, scala]

scala> :type spark org.apache.spark.sql.SparkSession

scala> :type spark.sharedState.globalTempViewManager org.apache.spark.sql.catalyst.catalog.GlobalTempViewManager


[[methods]] .GlobalTempViewManager API [cols="1,2",options="header",width="100%"] |=== | Method | Description

| <> a|

[source, scala]

clear(): Unit

| <> a|

[source, scala]

create( name: String, viewDefinition: LogicalPlan, overrideIfExists: Boolean): Unit


Registers (creates) a global temporary view (as a spark-sql-LogicalPlan.md[LogicalPlan]) by name

Used when SessionCatalog is requested to createGlobalTempView

| <> a|

[source, scala]

get( name: String): Option[LogicalPlan]


Finds the global view definition (as a spark-sql-LogicalPlan.md[LogicalPlan]) for the given name if available

Used when SessionCatalog is requested to getGlobalTempView, getTempViewOrPermanentTableMetadata, lookupRelation, isTemporaryTable, refreshTable

| <> a|

[source, scala]

listViewNames(pattern: String): Seq[String]

| <> a|

[source, scala]

remove(name: String): Boolean

| <> a|

[source, scala]

rename(oldName: String, newName: String): Boolean

| <> a|

[source, scala]

update(name: String, viewDefinition: LogicalPlan): Boolean

|===

GlobalTempViewManager is <> exclusively when SharedState is requested for <> (for the very first time only as it is cached).

[[database]] [[creating-instance]] GlobalTempViewManager takes the name of the database when created.

.Creating GlobalTempViewManager image::images/spark-sql-GlobalTempViewManager-creating-instance.png[align="center"]

[[internal-registries]] .GlobalTempViewManager's Internal Properties (e.g. Registries, Counters and Flags) [cols="1m,2",options="header",width="100%"] |=== | Name | Description

| viewDefinitions | [[viewDefinitions]] Registry of global temporary view definitions as <> per view name. |===

=== [[clear]] clear Method

[source, scala]

clear(): Unit

clear simply removes all the entries in the <> internal registry.

NOTE: clear is used when SessionCatalog is requested to reset (that happens to be exclusively in the Spark SQL internal tests).

=== [[create]] Creating (Registering) Global Temporary View (Definition) -- create Method

[source, scala]

create( name: String, viewDefinition: LogicalPlan, overrideIfExists: Boolean): Unit


create simply registers (adds) the input <> under the input name.

create throws an AnalysisException when the input overrideIfExists flag is off and the <> internal registry contains the input name.

Temporary view '[table]' already exists

NOTE: create is used when SessionCatalog is requested to createGlobalTempView (when <> and <> logical commands are executed).

=== [[get]] Retrieving Global View Definition Per Name -- get Method

[source, scala]

get(name: String): Option[LogicalPlan]

get simply returns the <> that was registered under the name if it defined.

NOTE: get is used when SessionCatalog is requested to getGlobalTempView, getTempViewOrPermanentTableMetadata, lookupRelation, isTemporaryTable or refreshTable.

=== [[listViewNames]] Listing Global Temporary Views For Pattern -- listViewNames Method

[source, scala]

listViewNames(pattern: String): Seq[String]

listViewNames simply gives a list of the global temporary views with names matching the input pattern.

listViewNames is used when SessionCatalog is requested to listTables

=== [[remove]] Removing (De-Registering) Global Temporary View -- remove Method

[source, scala]

remove(name: String): Boolean

remove simply tries to remove the name from the <> internal registry and returns true when removed or false otherwise.

remove is used when SessionCatalog is requested to drop a global temporary view or table.

=== [[rename]] rename Method

[source, scala]

rename(oldName: String, newName: String): Boolean

rename...FIXME

NOTE: rename is used when...FIXME

=== [[update]] update Method

[source, scala]

update(name: String, viewDefinition: LogicalPlan): Boolean

update...FIXME

update is used when SessionCatalog is requested to alter a global temporary view.