Skip to content

Commit 975373b

Browse files
authored
use global temp view (#1017)
1 parent 776c869 commit 975373b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

sqlmesh/core/engine_adapter/spark.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,10 @@ def merge(
9393
df = self.try_get_df(source_table)
9494
if self._use_spark_session and df is not None:
9595
pyspark_df = self._ensure_pyspark_df(df)
96-
temp_view_name = self._get_temp_table(target_table, table_only=True).sql(
97-
dialect=self.dialect
98-
)
99-
pyspark_df.createOrReplaceTempView(temp_view_name)
100-
query = exp.select(*column_names).from_(temp_view_name)
96+
temp_view = self._get_temp_table(target_table, table_only=True)
97+
pyspark_df.createOrReplaceGlobalTempView(temp_view.sql(dialect=self.dialect))
98+
temp_view.set("db", "global_temp")
99+
query = exp.select(*column_names).from_(temp_view.sql(dialect=self.dialect))
101100
super().merge(target_table, query, columns_to_types, unique_key)
102101
else:
103102
super().merge(target_table, source_table, columns_to_types, unique_key)

0 commit comments

Comments
 (0)