@@ -433,3 +433,101 @@ def create_schema(
433433 # No catalog qualification, use as-is
434434 logger .debug (f"No catalog detected, using original: { schema_name } " )
435435 super ().create_schema (schema_name , ignore_if_exists , ** kwargs )
436+
437+ def create_view (
438+ self ,
439+ view_name : t .Union [str , exp .Table ],
440+ query_or_df : t .Any ,
441+ columns_to_types : t .Optional [t .Dict [str , exp .DataType ]] = None ,
442+ replace : bool = True ,
443+ materialized : bool = False ,
444+ materialized_properties : t .Optional [t .Dict [str , t .Any ]] = None ,
445+ table_description : t .Optional [str ] = None ,
446+ column_descriptions : t .Optional [t .Dict [str , str ]] = None ,
447+ view_properties : t .Optional [t .Dict [str , exp .Expression ]] = None ,
448+ ** create_kwargs : t .Any ,
449+ ) -> None :
450+ """
451+ Override create_view to handle catalog-qualified view names.
452+ Fabric doesn't support 'CREATE VIEW [catalog].[schema].[view]' syntax.
453+ """
454+ logger .debug (f"create_view called with: { view_name } (type: { type (view_name )} )" )
455+
456+ # Handle exp.Table objects that might be catalog-qualified
457+ if isinstance (view_name , exp .Table ):
458+ if view_name .catalog :
459+ # Has catalog qualification - switch to catalog and use schema.table
460+ catalog_name = view_name .catalog
461+ schema_name = view_name .db or ""
462+ table_name = view_name .name
463+
464+ logger .debug (
465+ f"Detected exp.Table with catalog: catalog='{ catalog_name } ', schema='{ schema_name } ', table='{ table_name } '"
466+ )
467+
468+ # Switch to the catalog first
469+ self .set_current_catalog (catalog_name )
470+
471+ # Create new Table expression without catalog
472+ unqualified_view = exp .Table (this = table_name , db = schema_name )
473+
474+ super ().create_view (
475+ unqualified_view ,
476+ query_or_df ,
477+ columns_to_types ,
478+ replace ,
479+ materialized ,
480+ materialized_properties ,
481+ table_description ,
482+ column_descriptions ,
483+ view_properties ,
484+ ** create_kwargs ,
485+ )
486+ return
487+
488+ # Handle string view names that might be catalog-qualified
489+ elif isinstance (view_name , str ):
490+ # Check if it's in catalog.schema.view format
491+ parts = view_name .split ("." )
492+ if len (parts ) == 3 :
493+ # catalog.schema.view format
494+ catalog_name = parts [0 ].strip ('"[]' )
495+ schema_name = parts [1 ].strip ('"[]' )
496+ view_only = parts [2 ].strip ('"[]' )
497+ unqualified_view_str = f"{ schema_name } .{ view_only } "
498+ logger .debug (
499+ f"Detected catalog.schema.view format: catalog='{ catalog_name } ', unqualified='{ unqualified_view_str } '"
500+ )
501+
502+ # Switch to the catalog first
503+ self .set_current_catalog (catalog_name )
504+
505+ # Use just the schema.view name
506+ super ().create_view (
507+ unqualified_view_str ,
508+ query_or_df ,
509+ columns_to_types ,
510+ replace ,
511+ materialized ,
512+ materialized_properties ,
513+ table_description ,
514+ column_descriptions ,
515+ view_properties ,
516+ ** create_kwargs ,
517+ )
518+ return
519+
520+ # No catalog qualification, use as-is
521+ logger .debug (f"No catalog detected, using original: { view_name } " )
522+ super ().create_view (
523+ view_name ,
524+ query_or_df ,
525+ columns_to_types ,
526+ replace ,
527+ materialized ,
528+ materialized_properties ,
529+ table_description ,
530+ column_descriptions ,
531+ view_properties ,
532+ ** create_kwargs ,
533+ )
0 commit comments