Skip to content

Commit 2107a25

Browse files
authored
Fix: Use expression for current catalog (#1775)
1 parent 4353303 commit 2107a25

File tree

8 files changed

+7
-7
lines changed

8 files changed

+7
-7
lines changed

sqlmesh/core/engine_adapter/databricks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class DatabricksEngineAdapter(SparkEngineAdapter):
3131
array_element_selector="element",
3232
)
3333
CATALOG_SUPPORT = CatalogSupport.FULL_SUPPORT
34-
CURRENT_CATALOG_FUNCTION = "current_catalog"
3534
SUPPORTS_ROW_LEVEL_OP = True
3635

3736
def __init__(self, *args: t.Any, **kwargs: t.Any):

sqlmesh/core/engine_adapter/duckdb.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class DuckDBEngineAdapter(LogicalMergeMixin, GetCurrentCatalogFromFunctionMixin)
2020
DIALECT = "duckdb"
2121
SUPPORTS_TRANSACTIONS = False
2222
CATALOG_SUPPORT = CatalogSupport.FULL_SUPPORT
23-
CURRENT_CATALOG_FUNCTION = "current_catalog"
2423

2524
def set_current_catalog(self, catalog: str) -> None:
2625
"""Sets the catalog name of the current connection."""

sqlmesh/core/engine_adapter/mixins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,11 @@ def _create_view_properties(
252252

253253

254254
class GetCurrentCatalogFromFunctionMixin(EngineAdapter):
255-
CURRENT_CATALOG_FUNCTION = "current_catalog"
255+
CURRENT_CATALOG_EXPRESSION: exp.Expression = exp.func("current_catalog")
256256

257257
def get_current_catalog(self) -> t.Optional[str]:
258258
"""Returns the catalog name of the current connection."""
259-
result = self.fetchone(exp.select(exp.func(self.CURRENT_CATALOG_FUNCTION)))
259+
result = self.fetchone(exp.select(self.CURRENT_CATALOG_EXPRESSION))
260260
if result:
261261
return result[0]
262262
return None

sqlmesh/core/engine_adapter/mssql.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class MSSQLEngineAdapter(
4848
SUPPORTS_TUPLE_IN = False
4949
SUPPORTS_MATERIALIZED_VIEWS = False
5050
CATALOG_SUPPORT = CatalogSupport.REQUIRES_SET_CATALOG
51-
CURRENT_CATALOG_FUNCTION = "DB_NAME"
51+
CURRENT_CATALOG_EXPRESSION = exp.func("db_name")
5252

5353
@set_catalog()
5454
def columns(

sqlmesh/core/engine_adapter/postgres.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class PostgresEngineAdapter(
2727
DIALECT = "postgres"
2828
SUPPORTS_INDEXES = True
2929
HAS_VIEW_BINDING = True
30+
CURRENT_CATALOG_EXPRESSION = exp.column("current_catalog")
3031

3132
def _fetch_native_df(
3233
self, query: t.Union[exp.Expression, str], quote_identifiers: bool = False

sqlmesh/core/engine_adapter/redshift.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RedshiftEngineAdapter(
2828
DIALECT = "redshift"
2929
ESCAPE_JSON = True
3030
COLUMNS_TABLE = "SVV_COLUMNS" # Includes late-binding views
31-
CURRENT_CATALOG_FUNCTION = "current_database"
31+
CURRENT_CATALOG_EXPRESSION = exp.func("current_database")
3232

3333
@property
3434
def cursor(self) -> t.Any:

sqlmesh/core/engine_adapter/snowflake.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class SnowflakeEngineAdapter(GetCurrentCatalogFromFunctionMixin):
2323
SUPPORTS_MATERIALIZED_VIEW_SCHEMA = True
2424
SUPPORTS_CLONING = True
2525
CATALOG_SUPPORT = CatalogSupport.FULL_SUPPORT
26-
CURRENT_CATALOG_FUNCTION = "CURRENT_DATABASE"
26+
CURRENT_CATALOG_EXPRESSION = exp.func("current_database")
2727

2828
def _df_to_source_queries(
2929
self,

sqlmesh/core/engine_adapter/trino.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class TrinoEngineAdapter(
4343
# connector and then figure out how to get insert/overwrite to work correctly without it.
4444
SUPPORTS_TRANSACTIONS = False
4545
SUPPORTS_ROW_LEVEL_OP = False
46+
CURRENT_CATALOG_EXPRESSION = exp.column("current_catalog")
4647

4748
@property
4849
def connection(self) -> TrinoConnection:

0 commit comments

Comments
 (0)