pyspark.sql.DataFrame.createOrReplaceGlobalTempView

DataFrame.createOrReplaceGlobalTempView(name)[source]

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.

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")