Skip to content

Commit 39c8e61

Browse files
fix(powerbi): fixes direction of the dashboard-report lineage
1 parent 3df12dc commit 39c8e61

File tree

3 files changed

+48
-37
lines changed

3 files changed

+48
-37
lines changed

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

+34-23
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,7 @@ def to_datahub_dashboard_mcp(
666666
workspace: powerbi_data_classes.Workspace,
667667
chart_mcps: List[MetadataChangeProposalWrapper],
668668
user_mcps: List[MetadataChangeProposalWrapper],
669+
dashboard_edges: List[EdgeClass],
669670
) -> List[MetadataChangeProposalWrapper]:
670671
"""
671672
Map PowerBi dashboard to Datahub dashboard
@@ -695,6 +696,7 @@ def chart_custom_properties(dashboard: powerbi_data_classes.Dashboard) -> dict:
695696
lastModified=ChangeAuditStamps(),
696697
dashboardUrl=dashboard.webUrl,
697698
customProperties={**chart_custom_properties(dashboard)},
699+
dashboards=dashboard_edges,
698700
)
699701

700702
info_mcp = self.new_mcp(
@@ -933,7 +935,7 @@ def to_datahub_work_units(
933935
dashboard: powerbi_data_classes.Dashboard,
934936
workspace: powerbi_data_classes.Workspace,
935937
) -> List[EquableMetadataWorkUnit]:
936-
mcps = []
938+
mcps: List[MetadataChangeProposalWrapper] = []
937939

938940
logger.info(
939941
f"Converting dashboard={dashboard.displayName} to datahub dashboard"
@@ -945,9 +947,35 @@ def to_datahub_work_units(
945947
)
946948
# Convert tiles to charts
947949
ds_mcps, chart_mcps = self.to_datahub_chart(dashboard.tiles, workspace)
950+
951+
# collect all downstream reports
952+
downstream_dashboards_edges = []
953+
for t in dashboard.tiles:
954+
if t.report_id:
955+
report = workspace.reports.get(t.report_id)
956+
if report is None:
957+
# a title referencing a missed report was already reported during "fill_dashboards"
958+
continue
959+
960+
dashboard_urn = builder.make_dashboard_urn(
961+
platform=self.__config.platform_name,
962+
platform_instance=self.__config.platform_instance,
963+
name=report.get_urn_part(),
964+
)
965+
edge = EdgeClass(
966+
destinationUrn=dashboard_urn,
967+
sourceUrn=None,
968+
created=None,
969+
lastModified=None,
970+
properties=None,
971+
)
972+
downstream_dashboards_edges.append(edge)
973+
948974
# Lets convert dashboard to datahub dashboard
949975
dashboard_mcps: List[MetadataChangeProposalWrapper] = (
950-
self.to_datahub_dashboard_mcp(dashboard, workspace, chart_mcps, user_mcps)
976+
self.to_datahub_dashboard_mcp(
977+
dashboard, workspace, chart_mcps, user_mcps, downstream_dashboards_edges
978+
)
951979
)
952980

953981
# Now add MCPs in sequence
@@ -1054,7 +1082,6 @@ def report_to_dashboard(
10541082
report: powerbi_data_classes.Report,
10551083
chart_mcps: List[MetadataChangeProposalWrapper],
10561084
user_mcps: List[MetadataChangeProposalWrapper],
1057-
dashboard_edges: List[EdgeClass],
10581085
) -> List[MetadataChangeProposalWrapper]:
10591086
"""
10601087
Map PowerBi report to Datahub dashboard
@@ -1076,7 +1103,6 @@ def report_to_dashboard(
10761103
charts=chart_urn_list,
10771104
lastModified=ChangeAuditStamps(),
10781105
dashboardUrl=report.webUrl,
1079-
dashboards=dashboard_edges,
10801106
)
10811107

10821108
info_mcp = self.new_mcp(
@@ -1170,27 +1196,12 @@ def report_to_datahub_work_units(
11701196
ds_mcps = self.to_datahub_dataset(report.dataset, workspace)
11711197
chart_mcps = self.pages_to_chart(report.pages, workspace, ds_mcps)
11721198

1173-
# find all dashboards with a Tile referencing this report
1174-
downstream_dashboards_edges = []
1175-
for d in workspace.dashboards.values():
1176-
if any(t.report_id == report.id for t in d.tiles):
1177-
dashboard_urn = builder.make_dashboard_urn(
1178-
platform=self.__config.platform_name,
1179-
platform_instance=self.__config.platform_instance,
1180-
name=d.get_urn_part(),
1181-
)
1182-
edge = EdgeClass(
1183-
destinationUrn=dashboard_urn,
1184-
sourceUrn=None,
1185-
created=None,
1186-
lastModified=None,
1187-
properties=None,
1188-
)
1189-
downstream_dashboards_edges.append(edge)
1190-
11911199
# Let's convert report to datahub dashboard
11921200
report_mcps = self.report_to_dashboard(
1193-
workspace, report, chart_mcps, user_mcps, downstream_dashboards_edges
1201+
workspace,
1202+
report,
1203+
chart_mcps,
1204+
user_mcps,
11941205
)
11951206

11961207
# Now add MCPs in sequence

metadata-ingestion/tests/integration/powerbi/golden_test_container.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,13 @@
17441744
"path": "/dashboardUrl",
17451745
"value": "https://localhost/dashboards/web/1"
17461746
},
1747+
{
1748+
"op": "add",
1749+
"path": "/dashboards/urn:li:dashboard:(powerbi,reports.5b218778-e7a5-4d73-8187-f10824047715)",
1750+
"value": {
1751+
"destinationUrn": "urn:li:dashboard:(powerbi,reports.5b218778-e7a5-4d73-8187-f10824047715)"
1752+
}
1753+
},
17471754
{
17481755
"op": "add",
17491756
"path": "/lastModified",
@@ -2948,13 +2955,6 @@
29482955
"path": "/dashboardUrl",
29492956
"value": "https://app.powerbi.com/groups/f089354e-8366-4e18-aea3-4cb4a3a50b48/reports/5b218778-e7a5-4d73-8187-f10824047715"
29502957
},
2951-
{
2952-
"op": "add",
2953-
"path": "/dashboards/urn:li:dashboard:(powerbi,dashboards.7D668CAD-7FFC-4505-9215-655BCA5BEBAE)",
2954-
"value": {
2955-
"destinationUrn": "urn:li:dashboard:(powerbi,dashboards.7D668CAD-7FFC-4505-9215-655BCA5BEBAE)"
2956-
}
2957-
},
29582958
{
29592959
"op": "add",
29602960
"path": "/lastModified",

metadata-ingestion/tests/integration/powerbi/golden_test_report.json

+7-7
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,13 @@
10381038
"path": "/dashboardUrl",
10391039
"value": "https://localhost/dashboards/web/1"
10401040
},
1041+
{
1042+
"op": "add",
1043+
"path": "/dashboards/urn:li:dashboard:(powerbi,reports.5b218778-e7a5-4d73-8187-f10824047715)",
1044+
"value": {
1045+
"destinationUrn": "urn:li:dashboard:(powerbi,reports.5b218778-e7a5-4d73-8187-f10824047715)"
1046+
}
1047+
},
10411048
{
10421049
"op": "add",
10431050
"path": "/lastModified",
@@ -1993,13 +2000,6 @@
19932000
"path": "/dashboardUrl",
19942001
"value": "https://app.powerbi.com/groups/f089354e-8366-4e18-aea3-4cb4a3a50b48/reports/5b218778-e7a5-4d73-8187-f10824047715"
19952002
},
1996-
{
1997-
"op": "add",
1998-
"path": "/dashboards/urn:li:dashboard:(powerbi,dashboards.7D668CAD-7FFC-4505-9215-655BCA5BEBAE)",
1999-
"value": {
2000-
"destinationUrn": "urn:li:dashboard:(powerbi,dashboards.7D668CAD-7FFC-4505-9215-655BCA5BEBAE)"
2001-
}
2002-
},
20032003
{
20042004
"op": "add",
20052005
"path": "/lastModified",

0 commit comments

Comments
 (0)