Skip to content

Commit

Permalink
Add app used tables as upstreams of all charts
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamjagtap639 committed Feb 13, 2024
1 parent 191f0ff commit 6f97cc5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,17 @@ def _gen_dashboard_info_workunit(
).as_workunit()

def _gen_charts_workunit(
self, charts: List[Chart], app_id: str
self, charts: List[Chart], input_tables: List[QlikTable], app_id: str
) -> Iterable[MetadataWorkUnit]:
"""
Map Qlik Chart to Datahub Chart
"""
input_tables_urns: List[str] = []
for table in input_tables:
table_identifier = self._get_app_table_identifier(table)
if table_identifier:
input_tables_urns.append(self._gen_qlik_dataset_urn(table_identifier))

for chart in charts:
chart_urn = builder.make_chart_urn(
platform=self.platform,
Expand All @@ -274,6 +280,7 @@ def _gen_charts_workunit(
description=chart.visualization,
lastModified=ChangeAuditStampsClass(),
customProperties=custom_properties,
inputs=input_tables_urns,
),
).as_workunit()

Expand All @@ -283,21 +290,19 @@ def _gen_charts_workunit(
entity_urn=chart_urn,
)

def _gen_sheets_workunit(
self, sheets: List[Sheet], app_id: str
) -> Iterable[MetadataWorkUnit]:
def _gen_sheets_workunit(self, app: App) -> Iterable[MetadataWorkUnit]:
"""
Map Qlik Sheet to Datahub dashboard
"""
for sheet in sheets:
for sheet in app.sheets:
dashboard_urn = self._gen_dashboard_urn(sheet.id)

yield self._gen_entity_status_aspect(dashboard_urn)

yield self._gen_dashboard_info_workunit(sheet, app_id)
yield self._gen_dashboard_info_workunit(sheet, app.id)

yield from add_entity_to_container(
container_key=self._gen_app_key(app_id),
container_key=self._gen_app_key(app.id),
entity_type="dashboard",
entity_urn=dashboard_urn,
)
Expand All @@ -310,7 +315,7 @@ def _gen_sheets_workunit(
if self.config.ingest_owner and owner_username:
yield self._gen_entity_owner_aspect(dashboard_urn, owner_username)

yield from self._gen_charts_workunit(sheet.charts, app_id)
yield from self._gen_charts_workunit(sheet.charts, app.tables, app.id)

def _gen_app_table_upstream_lineage(
self, dataset_urn: str, table: QlikTable
Expand Down Expand Up @@ -446,7 +451,7 @@ def _gen_app_workunit(self, app: App) -> Iterable[MetadataWorkUnit]:
created=int(app.createdAt.timestamp() * 1000),
last_modified=int(app.updatedAt.timestamp() * 1000),
)
yield from self._gen_sheets_workunit(app.sheets, app.id)
yield from self._gen_sheets_workunit(app)
yield from self._gen_app_tables_workunit(app.tables, app.id)

def _gen_qlik_dataset_urn(self, dataset_identifier: str) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,11 +552,19 @@
"time": 0,
"actor": "urn:li:corpuser:unknown"
}
}
},
"inputs": [
{
"string": "urn:li:dataset:(urn:li:dataPlatform:qlik-sense,qlik_sense_platform.qri:qdf:space://ebw1euduywmui8p2bm7cor5oathzuyxvt0bircc2iru#jokg8u7cvizvgxwrfsyxru0ykr2rl2wfd5djph9bj5q#rrg6-1cerbo4ews9o--qup3toxhm5molizgy6_wcxje,PROD)"
},
{
"string": "urn:li:dataset:(urn:li:dataPlatform:qlik-sense,qlik_sense_platform.qri:qdf:space://ebw1euduywmui8p2bm7cor5oathzuyxvt0bircc2iru#_s2ws5rvxaarzazlmghwjhngq8znjagxptal6jlzoaw#fcj-h2tvmayi--l6fn0vqgpthf8kb2rj7sj0_ysrhgc,PROD)"
}
]
}
},
"systemMetadata": {
"lastObserved": 1707327546138,
"lastObserved": 1707803447230,
"runId": "qlik-sense-test",
"lastRunId": "no-run-id-provided"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,11 +511,19 @@
"time": 0,
"actor": "urn:li:corpuser:unknown"
}
}
},
"inputs": [
{
"string": "urn:li:dataset:(urn:li:dataPlatform:qlik-sense,qri:qdf:space://ebw1euduywmui8p2bm7cor5oathzuyxvt0bircc2iru#jokg8u7cvizvgxwrfsyxru0ykr2rl2wfd5djph9bj5q#rrg6-1cerbo4ews9o--qup3toxhm5molizgy6_wcxje,PROD)"
},
{
"string": "urn:li:dataset:(urn:li:dataPlatform:qlik-sense,qri:qdf:space://ebw1euduywmui8p2bm7cor5oathzuyxvt0bircc2iru#_s2ws5rvxaarzazlmghwjhngq8znjagxptal6jlzoaw#fcj-h2tvmayi--l6fn0vqgpthf8kb2rj7sj0_ysrhgc,PROD)"
}
]
}
},
"systemMetadata": {
"lastObserved": 1707327443026,
"lastObserved": 1707803447013,
"runId": "qlik-sense-test",
"lastRunId": "no-run-id-provided"
}
Expand Down

0 comments on commit 6f97cc5

Please sign in to comment.