Skip to content

Commit 671e22f

Browse files
Refactor: Resolve schema owner from ownerConfig
Co-authored-by: yourton.ma <yourton.ma@gmail.com>
1 parent 3c5630d commit 671e22f

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

ingestion/src/metadata/ingestion/source/database/database_service.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,34 @@ def get_owner_ref(self, table_name: str) -> Optional[EntityReferenceList]:
679679
"""
680680
try:
681681
parent_owner = None
682-
database_schema_entity = getattr(
683-
self.context.get(), "database_schema_entity", None
684-
)
685-
if database_schema_entity:
686-
schema_owners = database_schema_entity.owners
687-
if schema_owners and schema_owners.root:
688-
parent_owner = schema_owners.root[0].name
682+
683+
# Get parent owner from schema's ownerConfig resolution
684+
# We need to resolve the schema's owner first to enable proper inheritance
685+
if (
686+
hasattr(self.source_config, "ownerConfig")
687+
and self.source_config.ownerConfig
688+
):
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(
701+
metadata=self.metadata,
702+
owner_config=self.source_config.ownerConfig,
703+
entity_type="databaseSchema",
704+
entity_name=schema_fqn,
705+
parent_owner=database_owner,
706+
)
707+
708+
if schema_owner_ref and schema_owner_ref.root:
709+
parent_owner = schema_owner_ref.root[0].name
689710

690711
table_fqn = f"{self.context.get().database}.{self.context.get().database_schema}.{table_name}"
691712

0 commit comments

Comments
 (0)