Skip to content

Commit 38b82bb

Browse files
feat(fabric): Override drop schema
1 parent f4aad00 commit 38b82bb

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

sqlmesh/core/engine_adapter/fabric.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,35 @@ def set_current_catalog(self, catalog_name: str) -> None:
370370
logger.debug(f"Could not verify catalog switch: {e}")
371371

372372
logger.debug(f"Updated target catalog to '{catalog_name}' and closed connections")
373+
374+
def drop_schema(
375+
self,
376+
schema_name: t.Union[str, exp.Table],
377+
ignore_if_not_exists: bool = True,
378+
cascade: bool = False,
379+
**drop_args: t.Any,
380+
) -> None:
381+
"""
382+
Override drop_schema to handle catalog-qualified schema names.
383+
Fabric doesn't support 'DROP SCHEMA [catalog].[schema]' syntax.
384+
"""
385+
logger.debug(f"drop_schema called with: {schema_name} (type: {type(schema_name)})")
386+
387+
# If it's a string with a dot, assume it's catalog.schema format
388+
if isinstance(schema_name, str) and "." in schema_name:
389+
parts = schema_name.split(".", 1) # Split only on first dot
390+
catalog_name = parts[0].strip('"[]') # Remove quotes/brackets
391+
schema_only = parts[1].strip('"[]')
392+
logger.debug(
393+
f"Detected catalog.schema format: catalog='{catalog_name}', schema='{schema_only}'"
394+
)
395+
396+
# Switch to the catalog first
397+
self.set_current_catalog(catalog_name)
398+
399+
# Use just the schema name
400+
super().drop_schema(schema_only, ignore_if_not_exists, cascade, **drop_args)
401+
else:
402+
# No catalog qualification, use as-is
403+
logger.debug(f"No catalog detected, using original: {schema_name}")
404+
super().drop_schema(schema_name, ignore_if_not_exists, cascade, **drop_args)

0 commit comments

Comments
 (0)