Skip to content

Commit

Permalink
feat(ingest/tableau): include platform_instance in browse v1 path (da…
Browse files Browse the repository at this point in the history
  • Loading branch information
hsheth2 authored Jan 11, 2024
1 parent 8cb6d88 commit 990bb65
Show file tree
Hide file tree
Showing 4 changed files with 3,084 additions and 666 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
MetadataChangeEventClass,
MetadataChangeProposalClass,
StatusClass,
TagKeyClass,
TimeWindowSizeClass,
)
from datahub.telemetry import telemetry
Expand Down Expand Up @@ -173,11 +172,11 @@ def auto_materialize_referenced_tags(
yield wu

for urn in sorted(referenced_tags - tags_with_aspects):
tag_urn = TagUrn.create_from_string(urn)
tag_urn = TagUrn.from_string(urn)

yield MetadataChangeProposalWrapper(
entityUrn=urn,
aspect=TagKeyClass(name=tag_urn.get_entity_id()[0]),
aspect=tag_urn.to_key_aspect(),
).as_workunit()


Expand Down
29 changes: 23 additions & 6 deletions metadata-ingestion/src/datahub/ingestion/source/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,23 @@ def close(self) -> None:
self.server = None
super().close()

@property
def no_env_browse_prefix(self) -> str:
# Prefix to use with browse path (v1)
# This is for charts and dashboards.

platform_with_instance = (
f"{self.platform}/{self.config.platform_instance}"
if self.config.platform_instance
else self.platform
)
return f"/{platform_with_instance}"

@property
def dataset_browse_prefix(self) -> str:
# datasets also have the env in the browse path
return f"/{self.config.env.lower()}{self.no_env_browse_prefix}"

def _populate_usage_stat_registry(self) -> None:
if self.server is None:
return
Expand Down Expand Up @@ -1118,7 +1135,7 @@ def get_upstream_columns_of_fields_in_datasource(

def is_snowflake_urn(self, urn: str) -> bool:
return (
DatasetUrn.create_from_string(urn).get_data_platform_urn().platform_name
DatasetUrn.from_string(urn).get_data_platform_urn().platform_name
== "snowflake"
)

Expand Down Expand Up @@ -1328,7 +1345,7 @@ def emit_custom_sql_datasources(self) -> Iterable[MetadataWorkUnit]:
if project and datasource_name:
browse_paths = BrowsePathsClass(
paths=[
f"/{self.config.env.lower()}/{self.platform}/{project}/{datasource[c.NAME]}"
f"{self.dataset_browse_prefix}/{project}/{datasource[c.NAME]}"
]
)
dataset_snapshot.aspects.append(browse_paths)
Expand Down Expand Up @@ -1708,7 +1725,7 @@ def emit_datasource(

if browse_path:
browse_paths = BrowsePathsClass(
paths=[f"/{self.config.env.lower()}/{self.platform}/{browse_path}"]
paths=[f"{self.dataset_browse_prefix}/{browse_path}"]
)
dataset_snapshot.aspects.append(browse_paths)

Expand Down Expand Up @@ -1869,7 +1886,7 @@ def emit_table(
# Browse path
browse_paths = BrowsePathsClass(
paths=[
f"/{self.config.env.lower()}/{self.platform}/{path}"
f"{self.dataset_browse_prefix}/{path}"
for path in sorted(database_table.paths, key=lambda p: (len(p), p))
]
)
Expand Down Expand Up @@ -2372,7 +2389,7 @@ def get_browse_paths_aspect(
if project_luid in self.tableau_project_registry:
browse_paths = BrowsePathsClass(
paths=[
f"/{self.platform}/{self._project_luid_to_browse_path_name(project_luid)}"
f"{self.no_env_browse_prefix}/{self._project_luid_to_browse_path_name(project_luid)}"
f"/{workbook[c.NAME].replace('/', REPLACE_SLASH_CHAR)}"
]
)
Expand All @@ -2381,7 +2398,7 @@ def get_browse_paths_aspect(
# browse path
browse_paths = BrowsePathsClass(
paths=[
f"/{self.platform}/{workbook[c.PROJECT_NAME].replace('/', REPLACE_SLASH_CHAR)}"
f"{self.no_env_browse_prefix}/{workbook[c.PROJECT_NAME].replace('/', REPLACE_SLASH_CHAR)}"
f"/{workbook[c.NAME].replace('/', REPLACE_SLASH_CHAR)}"
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def transform_aspect(
tags = in_tags_aspect.tags
owners: List[OwnerClass] = []
for tag_class in tags:
tag_urn = TagUrn.create_from_string(tag_class.tag)
tag_urn = TagUrn.from_string(tag_class.tag)
tag_str = tag_urn.get_entity_id()[0]
re_match = re.search(self.config.tag_prefix, tag_str)
if re_match:
Expand Down
Loading

0 comments on commit 990bb65

Please sign in to comment.