Skip to content

Commit

Permalink
fix(tableau): assert error on parent name (#12392)
Browse files Browse the repository at this point in the history
Co-authored-by: Mayuri Nehate <[email protected]>
Co-authored-by: Harshal Sheth <[email protected]>
  • Loading branch information
3 people authored Jan 22, 2025
1 parent fbfa487 commit 96758e2
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions metadata-ingestion/src/datahub/ingestion/source/tableau/tableau.py
Original file line number Diff line number Diff line change
Expand Up @@ -1147,23 +1147,36 @@ def fetch_projects():
)
# Set parent project name
for _project_id, project in all_project_map.items():
if (
project.parent_id is not None
and project.parent_id in all_project_map
):
if project.parent_id is None:
continue

if project.parent_id in all_project_map:
project.parent_name = all_project_map[project.parent_id].name
else:
self.report.warning(
title="Incomplete project hierarchy",
message="Project details missing. Child projects will be ingested without reference to their parent project. We generally need Site Administrator Explorer permissions to extract the complete project hierarchy.",
context=f"Missing {project.parent_id}, referenced by {project.id} {project.project_name}",
)
project.parent_id = None

# Post-condition
assert all(
[
((project.parent_id is None) == (project.parent_name is None))
and (
project.parent_id is None
or project.parent_id in all_project_map
)
for project in all_project_map.values()
]
), "Parent project id and name should be consistent"

def set_project_path():
def form_path(project_id: str) -> List[str]:
cur_proj = all_project_map[project_id]
ancestors = [cur_proj.name]
while cur_proj.parent_id is not None:
if cur_proj.parent_id not in all_project_map:
self.report.warning(
"project-issue",
f"Parent project {cur_proj.parent_id} not found. We need Site Administrator Explorer permissions.",
)
break
cur_proj = all_project_map[cur_proj.parent_id]
ancestors = [cur_proj.name, *ancestors]
return ancestors
Expand Down

0 comments on commit 96758e2

Please sign in to comment.