diff --git a/ingestion/src/metadata/ingestion/source/dashboard/powerbi/metadata.py b/ingestion/src/metadata/ingestion/source/dashboard/powerbi/metadata.py index 16def2148ad7..ecc9540bc0b7 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/powerbi/metadata.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/powerbi/metadata.py @@ -675,6 +675,7 @@ def create_report_dashboard_lineage( ) -> Iterable[Either[CreateDashboardRequest]]: """Create lineage between report and dashboard""" try: + logger.debug(f"Processing to create report and dashboard lineage for dashboard: {dashboard_details.id}") charts = dashboard_details.tiles dashboard_fqn = fqn.build( self.metadata, @@ -686,9 +687,22 @@ def create_report_dashboard_lineage( entity=Dashboard, fqn=dashboard_fqn, ) + if not dashboard_entity: + logger.debug( + f"Dashboard entity not found to create lineage between report and dashboard for dashboard: {dashboard_details.id}" + ) + return for chart in charts or []: + if chart.reportId: + logger.debug(f"Dashboard's chart {chart.id} is linked with report id: {str(chart.reportId)}") # noqa: RUF010 + else: + logger.debug(f"Dashboard's chart {chart.id} is not linked with any report") + continue report = self._fetch_report_from_workspace(chart.reportId) if report: + logger.debug( + f"Fetched report details for report id: {str(chart.reportId)} from workspace data to create lineage with dashboard: {dashboard_details.id}" # noqa: RUF010 + ) report_fqn = fqn.build( self.metadata, entity_type=Dashboard, @@ -699,9 +713,19 @@ def create_report_dashboard_lineage( entity=Dashboard, fqn=report_fqn, ) - + if not report_entity: + logger.debug( + f"Report entity not found to create lineage between report={report.id} and dashboard={dashboard_details.id}" + ) if report_entity and dashboard_entity: + logger.debug( + f"Creating lineage between report={report.id} and dashboard={dashboard_details.id}" + ) yield self._get_add_lineage_request(to_entity=dashboard_entity, from_entity=report_entity) + else: + logger.debug( + f"Could not fetch report with report id: {str(chart.reportId)} from workspace data to create lineage with dashboard: {dashboard_details.id}" # noqa: RUF010 + ) except Exception as exc: # pylint: disable=broad-except yield Either( left=StackTraceError( @@ -729,6 +753,8 @@ def _get_dataset_ids_from_report_datasources(self, report_id: str) -> List[str]: ) if match: dataset_ids.append(match.group(1)) + if dataset_ids: + logger.debug(f"Extracted dataset IDs from report datasources API call for report_id={report_id}") return dataset_ids def create_datamodel_report_lineage( @@ -740,6 +766,7 @@ def create_datamodel_report_lineage( create the lineage between datamodel and report """ try: + logger.debug(f"Processing to create datamodel and report lineage for report: {dashboard_details.id}") report_fqn = fqn.build( self.metadata, entity_type=Dashboard, @@ -750,10 +777,19 @@ def create_datamodel_report_lineage( entity=Dashboard, fqn=report_fqn, ) + if not report_entity: + logger.debug( + f"Report entity not found to create lineage between datamodel and report for report: {dashboard_details.id}" + ) + return dataset_ids = [] if dashboard_details.datasetId: + logger.debug(f"Report linked datasetId is present in api response for report: {dashboard_details.id}") dataset_ids = [dashboard_details.datasetId] else: + logger.debug( + f"Processing to get report datasources from API to extract datasetIds for report: {dashboard_details.id} as datasetId is not present in api response" + ) dataset_ids = self._get_dataset_ids_from_report_datasources(report_id=dashboard_details.id) if dataset_ids: @@ -768,6 +804,10 @@ def create_datamodel_report_lineage( entity=DashboardDataModel, fqn=datamodel_fqn, ) + if not datamodel_entity: + logger.debug( + f"Data model entity not found for dataset_id={str(dataset_id)} while creating lineage with report={str(dashboard_details.id)}" # noqa: RUF010 + ) if datamodel_entity and report_entity: logger.debug( f"Creating lineage between datamodel={str(dataset_id)} and report={str(dashboard_details.id)}" # noqa: RUF010 @@ -778,7 +818,7 @@ def create_datamodel_report_lineage( ) else: logger.debug( - f"Skipping datamodel and report lineage for {dashboard_details.id} as datasetId is not found" + f"Skipping datamodel and report lineage for report: {dashboard_details.id} as datasetId is not found on api response and also could not be extracted from report datasources API call" ) except Exception as exc: # pylint: disable=broad-except @@ -2062,7 +2102,7 @@ def _fetch_dataset_from_workspace(self, dataset_id: Optional[str]) -> Optional[D return dataset_data return None - def _fetch_report_from_workspace(self, report_id: Optional[str]) -> Optional[Dataset]: # noqa: UP045 + def _fetch_report_from_workspace(self, report_id: Optional[str]) -> Optional[PowerBIReport]: # noqa: UP045 """ Method to search the report using id in the workspace dict """