Skip to content

Commit 96758e2

Browse files
sgomezvillamormayurinehatehsheth2
authored
fix(tableau): assert error on parent name (#12392)
Co-authored-by: Mayuri Nehate <[email protected]> Co-authored-by: Harshal Sheth <[email protected]>
1 parent fbfa487 commit 96758e2

File tree

1 file changed

+23
-10
lines changed
  • metadata-ingestion/src/datahub/ingestion/source/tableau

1 file changed

+23
-10
lines changed

metadata-ingestion/src/datahub/ingestion/source/tableau/tableau.py

+23-10
Original file line numberDiff line numberDiff line change
@@ -1147,23 +1147,36 @@ def fetch_projects():
11471147
)
11481148
# Set parent project name
11491149
for _project_id, project in all_project_map.items():
1150-
if (
1151-
project.parent_id is not None
1152-
and project.parent_id in all_project_map
1153-
):
1150+
if project.parent_id is None:
1151+
continue
1152+
1153+
if project.parent_id in all_project_map:
11541154
project.parent_name = all_project_map[project.parent_id].name
1155+
else:
1156+
self.report.warning(
1157+
title="Incomplete project hierarchy",
1158+
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.",
1159+
context=f"Missing {project.parent_id}, referenced by {project.id} {project.project_name}",
1160+
)
1161+
project.parent_id = None
1162+
1163+
# Post-condition
1164+
assert all(
1165+
[
1166+
((project.parent_id is None) == (project.parent_name is None))
1167+
and (
1168+
project.parent_id is None
1169+
or project.parent_id in all_project_map
1170+
)
1171+
for project in all_project_map.values()
1172+
]
1173+
), "Parent project id and name should be consistent"
11551174

11561175
def set_project_path():
11571176
def form_path(project_id: str) -> List[str]:
11581177
cur_proj = all_project_map[project_id]
11591178
ancestors = [cur_proj.name]
11601179
while cur_proj.parent_id is not None:
1161-
if cur_proj.parent_id not in all_project_map:
1162-
self.report.warning(
1163-
"project-issue",
1164-
f"Parent project {cur_proj.parent_id} not found. We need Site Administrator Explorer permissions.",
1165-
)
1166-
break
11671180
cur_proj = all_project_map[cur_proj.parent_id]
11681181
ancestors = [cur_proj.name, *ancestors]
11691182
return ancestors

0 commit comments

Comments
 (0)