@@ -680,33 +680,31 @@ def get_owner_ref(self, table_name: str) -> Optional[EntityReferenceList]:
680680 try :
681681 parent_owner = None
682682
683- # Get parent owner from schema's ownerConfig resolution
684- # We need to resolve the schema's owner first to enable proper inheritance
683+ # Get parent owner from schema entity
684+ # Since schema entity is not stored in context, we fetch it from the API
685685 if (
686686 hasattr (self .source_config , "ownerConfig" )
687687 and self .source_config .ownerConfig
688688 ):
689- schema_fqn = f"{ self .context .get ().database } .{ self .context .get ().database_schema } "
690-
691- # First, get the database owner for schema inheritance
692- database_owner = None
693- database_entity = getattr (self .context .get (), "database_entity" , None )
694- if database_entity :
695- db_owners = database_entity .owners
696- if db_owners and db_owners .root :
697- database_owner = db_owners .root [0 ].name
698-
699- # Resolve schema owner (which may inherit from database)
700- schema_owner_ref = get_owner_from_config (
689+ schema_fqn = fqn .build (
701690 metadata = self .metadata ,
702- owner_config = self . source_config . ownerConfig ,
703- entity_type = "databaseSchema" ,
704- entity_name = schema_fqn ,
705- parent_owner = database_owner ,
691+ entity_type = DatabaseSchema ,
692+ service_name = self . context . get (). database_service ,
693+ database_name = self . context . get (). database ,
694+ schema_name = self . context . get (). database_schema ,
706695 )
707696
708- if schema_owner_ref and schema_owner_ref .root :
709- parent_owner = schema_owner_ref .root [0 ].name
697+ # Fetch schema entity to get its resolved owner
698+ try :
699+ schema_entity = self .metadata .get_by_name (
700+ entity = DatabaseSchema ,
701+ fqn = schema_fqn ,
702+ fields = ["owners" ],
703+ )
704+ if schema_entity and schema_entity .owners and schema_entity .owners .root :
705+ parent_owner = schema_entity .owners .root [0 ].name
706+ except Exception as exc :
707+ logger .debug (f"Could not fetch schema entity for owner inheritance: { exc } " )
710708
711709 table_fqn = f"{ self .context .get ().database } .{ self .context .get ().database_schema } .{ table_name } "
712710
0 commit comments