Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes 17648: add tags and description for tableau published data source #17678

Merged
merged 6 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,24 @@ def get_owner_ref(
logger.warning(f"Could not fetch owner data due to {err}")
return None

@staticmethod
def _get_data_models_tags(dataModels: [DataSource]) -> Set[str]:
nicor88 marked this conversation as resolved.
Show resolved Hide resolved
"""
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]]:
Expand All @@ -160,8 +178,14 @@ def yield_tags(
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",
Expand Down Expand Up @@ -201,13 +225,23 @@ def _create_datamodel_request(
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),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -121,6 +129,8 @@ class UpstreamTable(BaseModel):
class DataSource(BaseModel):
id: str
name: Optional[str] = None
description: Optional[str] = None
tags: Optional[List[TableauDataModelTag]] = []
OnkarVO7 marked this conversation as resolved.
Show resolved Hide resolved
fields: Optional[List[DatasourceField]] = None
upstreamTables: Optional[List[UpstreamTable]] = None
upstreamDatasources: Optional[List["DataSource"]] = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
upstreamDatasources{{
id
name
description
tags {{
name
}}
fields {{
id
name
Expand Down
2 changes: 1 addition & 1 deletion ingestion/tests/unit/topology/dashboard/test_tableau.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Test Domo Dashboard using the topology
Test Tableau Dashboard
"""

from unittest import TestCase
Expand Down
Loading