diff --git a/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py b/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py index b67439ac1bf..1d0887ed037 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py @@ -148,6 +148,24 @@ class TableauSource(DashboardServiceSource): logger.warning(f"Could not fetch owner data due to {err}") return None + @staticmethod + def _get_data_models_tags(dataModels: [DataSource]) -> Set[str]: + """ + Get the tags from the data model in the upstreamDatasources + """ + tags = set() + try: + for data_model in dataModels: + # tags seems to be available for upstreamDatasources only, not for dataModels + for upstream_source in data_model.upstreamDatasources or []: + for tag in upstream_source.tags: + tags.add(tag.name) + except Exception as exc: + logger.debug(traceback.format_exc()) + logger.warning(f"Error fetching tags from data models: {exc}") + + return tags + def yield_tags( self, dashboard_details: TableauDashboard ) -> Iterable[Either[OMetaTagAndClassification]]: @@ -160,8 +178,14 @@ class TableauSource(DashboardServiceSource): for elem in container: tags.update(elem.tags) + _tags = {tag.label for tag in tags} + # retrieve tags from data models + _data_models_tags = self._get_data_models_tags(dashboard_details.dataModels) + + _all_tags = _tags.union(_data_models_tags) + yield from get_ometa_tag_and_classification( - tags=[tag.label for tag in tags], + tags=[tag for tag in _all_tags], classification_name=TABLEAU_TAG_CATEGORY, tag_description="Tableau Tag", classification_description="Tags associated with tableau entities", @@ -201,13 +225,23 @@ class TableauSource(DashboardServiceSource): self.status.filter(data_model_name, "Data model filtered out.") return try: + data_model_tags = data_model.tags or [] data_model_request = CreateDashboardDataModelRequest( name=EntityName(data_model.id), displayName=data_model_name, + description=Markdown(data_model.description) + if data_model.description + else None, service=FullyQualifiedEntityName(self.context.get().dashboard_service), dataModelType=data_model_type.value, serviceType=DashboardServiceType.Tableau.value, columns=self.get_column_info(data_model), + tags=get_tag_labels( + metadata=self.metadata, + tags=[tag.name for tag in data_model_tags], + classification_name=TABLEAU_TAG_CATEGORY, + include_tags=self.source_config.includeTags, + ), sql=self._get_datamodel_sql_query(data_model=data_model), owners=self.get_owner_ref(dashboard_details=dashboard_details), ) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py b/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py index 083f461bd73..10837cac04f 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py @@ -58,6 +58,14 @@ class TableauTag(BaseModel): label: str +class TableauDataModelTag(BaseModel): + """ + Aux class for Tag object for Tableau Data Model + """ + + name: str + + class TableauOwner(TableauBaseModel): """ Aux class for Owner object of the tableau_api_lib response @@ -121,6 +129,8 @@ class UpstreamTable(BaseModel): class DataSource(BaseModel): id: str name: Optional[str] = None + description: Optional[str] = None + tags: Optional[List[TableauDataModelTag]] = [] fields: Optional[List[DatasourceField]] = None upstreamTables: Optional[List[UpstreamTable]] = None upstreamDatasources: Optional[List["DataSource"]] = None diff --git a/ingestion/src/metadata/ingestion/source/dashboard/tableau/queries.py b/ingestion/src/metadata/ingestion/source/dashboard/tableau/queries.py index dab4c4c9c64..bb03818524e 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/tableau/queries.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/tableau/queries.py @@ -26,6 +26,10 @@ workbooks(filter:{{luid: "{workbook_id}"}}){{ upstreamDatasources{{ id name + description + tags {{ + name + }} fields {{ id name diff --git a/ingestion/tests/unit/topology/dashboard/test_tableau.py b/ingestion/tests/unit/topology/dashboard/test_tableau.py index b92b1aa0f5b..4bb68fa2c36 100644 --- a/ingestion/tests/unit/topology/dashboard/test_tableau.py +++ b/ingestion/tests/unit/topology/dashboard/test_tableau.py @@ -1,5 +1,5 @@ """ -Test Domo Dashboard using the topology +Test Tableau Dashboard """ from unittest import TestCase