From e9ec12d420f058165d153f7c8ae87d720002f8da Mon Sep 17 00:00:00 2001 From: Aseem Bansal Date: Fri, 7 Jun 2024 17:50:49 +0530 Subject: [PATCH] fix(ingest/qlik): improve logging for debug (#10659) --- .../datahub/ingestion/source/qlik_sense/config.py | 2 ++ .../ingestion/source/qlik_sense/data_classes.py | 4 ++-- .../datahub/ingestion/source/qlik_sense/qlik_api.py | 13 ++++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/config.py b/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/config.py index eb0b9d02d865e..b5547e8a8ae9e 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/config.py +++ b/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/config.py @@ -93,6 +93,8 @@ class Constant: # Personal entity constants PERSONAL_SPACE_ID = "personal-space-id" PERSONAL_SPACE_NAME = "personal_space" + # Hypercube + HYPERCUBE = "qHyperCube" @dataclass diff --git a/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/data_classes.py b/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/data_classes.py index c30b456253e06..672fcbceb0603 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/data_classes.py +++ b/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/data_classes.py @@ -164,8 +164,8 @@ class Chart(BaseModel): @root_validator(pre=True) def update_values(cls, values: Dict) -> Dict: values[Constant.QID] = values[Constant.QINFO][Constant.QID] - values["qDimension"] = values["qHyperCube"]["qDimensionInfo"] - values["qMeasure"] = values["qHyperCube"]["qMeasureInfo"] + values["qDimension"] = values[Constant.HYPERCUBE]["qDimensionInfo"] + values["qMeasure"] = values[Constant.HYPERCUBE]["qMeasureInfo"] return values diff --git a/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/qlik_api.py b/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/qlik_api.py index d7a040ff5f0a0..31b0731aaa751 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/qlik_api.py +++ b/metadata-ingestion/src/datahub/ingestion/source/qlik_sense/qlik_api.py @@ -113,7 +113,13 @@ def _get_chart( method="GetChild", params={"qId": chart_id} ) response = websocket_connection.websocket_send_request(method="GetLayout") - return Chart.parse_obj(response[Constant.QLAYOUT]) + q_layout = response[Constant.QLAYOUT] + if Constant.HYPERCUBE not in q_layout: + logger.warning( + f"Chart with id {chart_id} of sheet {sheet_id} does not have hypercube. q_layout: {q_layout}" + ) + return None + return Chart.parse_obj(q_layout) except Exception as e: self._log_http_error( message=f"Unable to fetch chart {chart_id} of sheet {sheet_id}. Exception: {e}" @@ -135,6 +141,11 @@ def _get_sheet( # That means sheet is private sheet return None sheet = Sheet.parse_obj(sheet_dict[Constant.QMETA]) + if Constant.QCHILDLIST not in sheet_dict: + logger.warning( + f"Sheet {sheet.title} with id {sheet_id} does not have any charts. sheet_dict: {sheet_dict}" + ) + return sheet for i, chart_dict in enumerate( sheet_dict[Constant.QCHILDLIST][Constant.QITEMS] ):