mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-09 07:23:39 +00:00
fixes 17648: add tags and description for tableau published data source (#17678)
* tableau data-source tags and description * tweaks * PR review * change test description * black formatting
This commit is contained in:
parent
a477e23854
commit
d068a59aa8
@ -148,6 +148,24 @@ class TableauSource(DashboardServiceSource):
|
|||||||
logger.warning(f"Could not fetch owner data due to {err}")
|
logger.warning(f"Could not fetch owner data due to {err}")
|
||||||
return None
|
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(
|
def yield_tags(
|
||||||
self, dashboard_details: TableauDashboard
|
self, dashboard_details: TableauDashboard
|
||||||
) -> Iterable[Either[OMetaTagAndClassification]]:
|
) -> Iterable[Either[OMetaTagAndClassification]]:
|
||||||
@ -160,8 +178,14 @@ class TableauSource(DashboardServiceSource):
|
|||||||
for elem in container:
|
for elem in container:
|
||||||
tags.update(elem.tags)
|
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(
|
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,
|
classification_name=TABLEAU_TAG_CATEGORY,
|
||||||
tag_description="Tableau Tag",
|
tag_description="Tableau Tag",
|
||||||
classification_description="Tags associated with tableau entities",
|
classification_description="Tags associated with tableau entities",
|
||||||
@ -201,13 +225,23 @@ class TableauSource(DashboardServiceSource):
|
|||||||
self.status.filter(data_model_name, "Data model filtered out.")
|
self.status.filter(data_model_name, "Data model filtered out.")
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
|
data_model_tags = data_model.tags or []
|
||||||
data_model_request = CreateDashboardDataModelRequest(
|
data_model_request = CreateDashboardDataModelRequest(
|
||||||
name=EntityName(data_model.id),
|
name=EntityName(data_model.id),
|
||||||
displayName=data_model_name,
|
displayName=data_model_name,
|
||||||
|
description=Markdown(data_model.description)
|
||||||
|
if data_model.description
|
||||||
|
else None,
|
||||||
service=FullyQualifiedEntityName(self.context.get().dashboard_service),
|
service=FullyQualifiedEntityName(self.context.get().dashboard_service),
|
||||||
dataModelType=data_model_type.value,
|
dataModelType=data_model_type.value,
|
||||||
serviceType=DashboardServiceType.Tableau.value,
|
serviceType=DashboardServiceType.Tableau.value,
|
||||||
columns=self.get_column_info(data_model),
|
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),
|
sql=self._get_datamodel_sql_query(data_model=data_model),
|
||||||
owners=self.get_owner_ref(dashboard_details=dashboard_details),
|
owners=self.get_owner_ref(dashboard_details=dashboard_details),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -58,6 +58,14 @@ class TableauTag(BaseModel):
|
|||||||
label: str
|
label: str
|
||||||
|
|
||||||
|
|
||||||
|
class TableauDataModelTag(BaseModel):
|
||||||
|
"""
|
||||||
|
Aux class for Tag object for Tableau Data Model
|
||||||
|
"""
|
||||||
|
|
||||||
|
name: str
|
||||||
|
|
||||||
|
|
||||||
class TableauOwner(TableauBaseModel):
|
class TableauOwner(TableauBaseModel):
|
||||||
"""
|
"""
|
||||||
Aux class for Owner object of the tableau_api_lib response
|
Aux class for Owner object of the tableau_api_lib response
|
||||||
@ -121,6 +129,8 @@ class UpstreamTable(BaseModel):
|
|||||||
class DataSource(BaseModel):
|
class DataSource(BaseModel):
|
||||||
id: str
|
id: str
|
||||||
name: Optional[str] = None
|
name: Optional[str] = None
|
||||||
|
description: Optional[str] = None
|
||||||
|
tags: Optional[List[TableauDataModelTag]] = []
|
||||||
fields: Optional[List[DatasourceField]] = None
|
fields: Optional[List[DatasourceField]] = None
|
||||||
upstreamTables: Optional[List[UpstreamTable]] = None
|
upstreamTables: Optional[List[UpstreamTable]] = None
|
||||||
upstreamDatasources: Optional[List["DataSource"]] = None
|
upstreamDatasources: Optional[List["DataSource"]] = None
|
||||||
|
|||||||
@ -26,6 +26,10 @@ workbooks(filter:{{luid: "{workbook_id}"}}){{
|
|||||||
upstreamDatasources{{
|
upstreamDatasources{{
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
description
|
||||||
|
tags {{
|
||||||
|
name
|
||||||
|
}}
|
||||||
fields {{
|
fields {{
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
"""
|
"""
|
||||||
Test Domo Dashboard using the topology
|
Test Tableau Dashboard
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user