nxcals.api.extraction.data.builders.DataFrame.createOrReplaceGlobalTempView

DataFrame.createOrReplaceGlobalTempView(name: str) None

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

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

New in version 2.2.0.

Changed in version 3.4.0: Supports Spark Connect.

Parameters:

name (str) – Name of the view.

Examples

Create a global temporary view.

>>> df = spark.createDataFrame([(2, "Alice"), (5, "Bob")], schema=["age", "name"])
>>> df.createOrReplaceGlobalTempView("people")

Replace the global temporary view.

>>> df2 = df.filter(df.age > 3)
>>> df2.createOrReplaceGlobalTempView("people")
>>> df3 = spark.sql("SELECT * FROM global_temp.people")
>>> sorted(df3.collect()) == sorted(df2.collect())
True
>>> spark.catalog.dropGlobalTempView("people")
True