From 2e0822b830b798dc238974daaf136369a2cb72e4 Mon Sep 17 00:00:00 2001 From: Abdallah Serghine <76706155+KylixSerg@users.noreply.github.com> Date: Wed, 2 Apr 2025 11:53:30 +0200 Subject: [PATCH] ISSUE-20427: fix tableau ingestion for null upstream table queries (#20428) For tableau ingestion, code does not handle properly null upstream custom table queries and null values for table OM entities. Co-authored-by: Abdallah Serghine Co-authored-by: Pere Miquel Brull --- .../ingestion/source/dashboard/tableau/metadata.py | 1 + .../metadata/ingestion/source/dashboard/tableau/models.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py b/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py index 136e9a94ade..044a08d9d89 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/tableau/metadata.py @@ -895,6 +895,7 @@ class TableauSource(DashboardServiceSource): [ TableAndQuery(table=table, query=custom_sql_table.query) for table in from_entities + if table is not None ] ) diff --git a/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py b/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py index 9c56ce9e673..26b522768c8 100644 --- a/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py +++ b/ingestion/src/metadata/ingestion/source/dashboard/tableau/models.py @@ -144,6 +144,14 @@ class UpstreamTable(BaseModel): database: Optional[TableauDatabase] = None referencedByQueries: Optional[List[CustomSQLTable]] = None + @validator("referencedByQueries", pre=True) + @classmethod + def filter_none_queries(cls, v): + """Filter out CustomSQLTable items where query==None.""" + if v is None: + return None + return [item for item in v if item.get("query") is not None] + class DataSource(BaseModel): id: str