Skip to content

Commit 154b56e

Browse files
authored
Fix: Include catalog if available when calling USE SCHEMA in snowflake (#2556)
1 parent f92dfd1 commit 154b56e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sqlmesh/core/engine_adapter/snowflake.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ def query_factory() -> Query:
9090
#
9191
# The above issue has already been fixed upstream, but we keep the following
9292
# line anyway in order to support a wider range of Snowflake versions.
93-
self.cursor.execute(f'USE SCHEMA "{temp_table.db}"')
93+
schema = f'"{temp_table.db}"'
94+
if temp_table.catalog:
95+
schema = f'"{temp_table.catalog}".{schema}'
96+
self.cursor.execute(f"USE SCHEMA {schema}")
9497

9598
# See: https://stackoverflow.com/a/75627721
9699
for column, kind in columns_to_types.items():

0 commit comments

Comments
 (0)