From 28b4df70046a163b9ba7f05e95358717ca4cb509 Mon Sep 17 00:00:00 2001 From: isura-nimalasiri Date: Wed, 3 Jul 2024 14:41:19 +0100 Subject: [PATCH] Check schema metadata --- .../src/datahub/ingestion/source/tableau.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/tableau.py b/metadata-ingestion/src/datahub/ingestion/source/tableau.py index 798d2de577d700..229655c45ce4ce 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/tableau.py +++ b/metadata-ingestion/src/datahub/ingestion/source/tableau.py @@ -144,6 +144,8 @@ OwnershipTypeClass, SubTypesClass, ViewPropertiesClass, + SchemaMetadataClass, + EditableSchemaMetadataClass ) from datahub.sql_parsing.sql_parsing_result_utils import ( transform_parsing_result_to_in_tables_schemas, @@ -2250,7 +2252,13 @@ def emit_table( tableau_columns, database_table.parsed_columns ) if schema_metadata is not None: - dataset_snapshot.aspects.append(schema_metadata) + # Check if table already has schema metadata + current_schema_aspect = self.ctx.graph.get_aspect(entity_urn=database_table.urn, aspect_type=SchemaMetadataClass) + current_editable_schema_aspect = self.ctx.graph.get_aspect(entity_urn=database_table.urn, aspect_type=EditableSchemaMetadataClass) + if current_schema_aspect or current_editable_schema_aspect: + logger.debug(f"Table {database_table.urn} already has schema metadata, skipping") + else: + dataset_snapshot.aspects.append(schema_metadata) yield self.get_metadata_change_event(dataset_snapshot)