mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-09-01 21:23:10 +00:00
Minor: Improve UC owner ingestion (#21741)
* Minor: Improve UC owner ingestion * lint
This commit is contained in:
parent
6fd5778219
commit
d20d278c4b
@ -340,7 +340,7 @@ class UnitycatalogSource(
|
|||||||
schema_name=schema_name,
|
schema_name=schema_name,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
owners=self.get_owner_ref(table_name),
|
owners=self.get_owner_ref(table.owner),
|
||||||
)
|
)
|
||||||
yield Either(right=table_request)
|
yield Either(right=table_request)
|
||||||
|
|
||||||
@ -403,6 +403,7 @@ class UnitycatalogSource(
|
|||||||
)
|
)
|
||||||
if referred_table_fqn:
|
if referred_table_fqn:
|
||||||
for parent_column in column.parent_columns:
|
for parent_column in column.parent_columns:
|
||||||
|
# pylint: disable=protected-access
|
||||||
col_fqn = fqn._build(referred_table_fqn, parent_column, quote=False)
|
col_fqn = fqn._build(referred_table_fqn, parent_column, quote=False)
|
||||||
if col_fqn:
|
if col_fqn:
|
||||||
referred_column_fqns.append(FullyQualifiedEntityName(col_fqn))
|
referred_column_fqns.append(FullyQualifiedEntityName(col_fqn))
|
||||||
@ -419,6 +420,7 @@ class UnitycatalogSource(
|
|||||||
|
|
||||||
return table_constraints
|
return table_constraints
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
def update_table_constraints(
|
def update_table_constraints(
|
||||||
self, table_constraints, foreign_columns, columns
|
self, table_constraints, foreign_columns, columns
|
||||||
) -> List[TableConstraint]:
|
) -> List[TableConstraint]:
|
||||||
@ -524,18 +526,25 @@ class UnitycatalogSource(
|
|||||||
def close(self):
|
def close(self):
|
||||||
"""Nothing to close"""
|
"""Nothing to close"""
|
||||||
|
|
||||||
def get_owner_ref(self, table_name: str) -> Optional[EntityReferenceList]:
|
# pylint: disable=arguments-renamed
|
||||||
|
def get_owner_ref(
|
||||||
|
self, table_owner: Optional[str]
|
||||||
|
) -> Optional[EntityReferenceList]:
|
||||||
"""
|
"""
|
||||||
Method to process the table owners
|
Method to process the table owners
|
||||||
"""
|
"""
|
||||||
|
if self.source_config.includeOwners is False:
|
||||||
|
return None
|
||||||
try:
|
try:
|
||||||
full_table_name = f"{self.context.get().database}.{self.context.get().database_schema}.{table_name}"
|
if not table_owner or not isinstance(table_owner, str):
|
||||||
owner = self.api_client.get_owner_info(full_table_name)
|
return None
|
||||||
if not owner:
|
owner_ref = self.metadata.get_reference_by_email(email=table_owner)
|
||||||
return
|
if owner_ref:
|
||||||
owner_ref = self.metadata.get_reference_by_email(email=owner)
|
return owner_ref
|
||||||
|
table_name = table_owner.split("@")[0]
|
||||||
|
owner_ref = self.metadata.get_reference_by_name(name=table_name)
|
||||||
return owner_ref
|
return owner_ref
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
logger.warning(f"Error processing owner for table {table_name}: {exc}")
|
logger.warning(f"Error processing owner {table_owner}: {exc}")
|
||||||
return
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user