pyspark.sql.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.

Examples

>>> df.createOrReplaceGlobalTempView("people")
>>> 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