From 1cbe60a5b21742453655f40af9288552f0cd1ea5 Mon Sep 17 00:00:00 2001 From: Harshal Sheth Date: Wed, 12 Oct 2022 22:34:35 +0000 Subject: [PATCH] feat(ingest/tableau): support dashboard tags (#6185) --- .../src/datahub/ingestion/source/tableau.py | 13 +++++++++---- .../src/datahub/ingestion/source/tableau_common.py | 3 +++ .../integration/tableau/tableau_mces_golden.json | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/tableau.py b/metadata-ingestion/src/datahub/ingestion/source/tableau.py index c61d6ac3ea6264..3657548bd0d755 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/tableau.py +++ b/metadata-ingestion/src/datahub/ingestion/source/tableau.py @@ -1099,9 +1099,7 @@ def emit_sheets_as_charts(self, workbook: Dict) -> Iterable[MetadataWorkUnit]: # Tags tag_list = sheet.get("tags", []) if tag_list and self.config.ingest_tags: - tag_list_str = [ - t.get("name", "").upper() for t in tag_list if t is not None - ] + tag_list_str = [t.get("name", "") for t in tag_list if t is not None] chart_snapshot.aspects.append( builder.make_global_tag_aspect_with_tag_list(tag_list_str) ) @@ -1140,7 +1138,7 @@ def emit_workbook_as_container(self, workbook: Dict) -> Iterable[MetadataWorkUni tag_list = workbook.get("tags", []) tag_list_str = ( - [t.get("name", "").upper() for t in tag_list if t is not None] + [t.get("name", "") for t in tag_list if t is not None] if (tag_list and self.config.ingest_tags) else None ) @@ -1246,6 +1244,13 @@ def emit_dashboards(self, workbook: Dict) -> Iterable[MetadataWorkUnit]: ) dashboard_snapshot.aspects.append(dashboard_info_class) + tag_list = dashboard.get("tags", []) + if tag_list and self.config.ingest_tags: + tag_list_str = [t.get("name", "") for t in tag_list if t is not None] + dashboard_snapshot.aspects.append( + builder.make_global_tag_aspect_with_tag_list(tag_list_str) + ) + if self.config.extract_usage_stats: # dashboard_snapshot doesn't support the stat aspect as list element and hence need to emit MetadataWorkUnit wu = self._get_dashboard_stat_wu(dashboard, dashboard_urn) diff --git a/metadata-ingestion/src/datahub/ingestion/source/tableau_common.py b/metadata-ingestion/src/datahub/ingestion/source/tableau_common.py index 141d5b30a43d33..d93320dd664e7f 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/tableau_common.py +++ b/metadata-ingestion/src/datahub/ingestion/source/tableau_common.py @@ -127,6 +127,9 @@ class MetadataQueryException(Exception): id name } + tags { + name + } } embeddedDatasources { id diff --git a/metadata-ingestion/tests/integration/tableau/tableau_mces_golden.json b/metadata-ingestion/tests/integration/tableau/tableau_mces_golden.json index 9cc3b0906595ce..574c8f5436e3bf 100644 --- a/metadata-ingestion/tests/integration/tableau/tableau_mces_golden.json +++ b/metadata-ingestion/tests/integration/tableau/tableau_mces_golden.json @@ -597,7 +597,7 @@ "changeType": "UPSERT", "aspectName": "globalTags", "aspect": { - "value": "{\"tags\": [{\"tag\": \"urn:li:tag:TAGSHEET3\"}]}", + "value": "{\"tags\": [{\"tag\": \"urn:li:tag:TagSheet3\"}]}", "contentType": "application/json" }, "systemMetadata": { @@ -817,7 +817,7 @@ "com.linkedin.pegasus2avro.common.GlobalTags": { "tags": [ { - "tag": "urn:li:tag:TAGSHEET3" + "tag": "urn:li:tag:TagSheet3" } ] }