Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
id: db219fef17
question: How do you share a DataFrame across multiple Spark sessions?
sort_order: 114
---

Spark provides **Global Temporary Views** to share DataFrames across different Spark sessions within the same Spark application.
Unlike regular temporary views, global temporary views are accessible from any session.
**Step 1: Create a Global Temporary View**
```python
# Create a global temporary view
df.createOrReplaceGlobalTempView('trips_global')
```
This registers the DataFrame as a global temporary view named `trips_global`.
**Step 2: Query the Global View from Any Session**
```python
spark.sql("SELECT * FROM global_temp.trips_global").show()
```
Global temporary views are stored in the `global_temp` database and must be referenced using the `global_temp.` prefix.