From 34e0007f4172d88732578a7b852e677073f4676f Mon Sep 17 00:00:00 2001 From: Daniel Ford Date: Tue, 24 Oct 2023 09:44:05 +0100 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Maiara Reinaldo <72740386+maiarareinaldo@users.noreply.github.com> --- .../src/datahub/ingestion/source/tableau.py | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/metadata-ingestion/src/datahub/ingestion/source/tableau.py b/metadata-ingestion/src/datahub/ingestion/source/tableau.py index b43328200ee2b..fa2b9ce63c77b 100644 --- a/metadata-ingestion/src/datahub/ingestion/source/tableau.py +++ b/metadata-ingestion/src/datahub/ingestion/source/tableau.py @@ -516,18 +516,18 @@ def __init__( self.ignore_upstream_lineage_platforms = [] # if ignore upstream lineage platforms doesn't contain "postgres", then consult the upstream_postgres_database_whitelist - if "postgres" not in self.ignore_upstream_lineage_platforms: - if self.config.upstream_postgres_database_whitelist: - self.upstream_postgres_database_whitelist = [ - x.strip() - for x in ( - self.config.upstream_postgres_database_whitelist.split(",") - ) - ] - else: - # return empty list if the config is not set - self.upstream_postgres_database_whitelist = [] + if ( + "postgres" not in self.ignore_upstream_lineage_platforms + and self.config.upstream_postgres_database_whitelist + ): + self.upstream_postgres_database_whitelist = [ + x.strip() + for x in ( + self.config.upstream_postgres_database_whitelist.split(",") + ) + ] else: + # return empty list if the config is not set self.upstream_postgres_database_whitelist = [] @@ -1043,12 +1043,7 @@ def get_upstream_tables(self, tables, datasource_name, browse_path, is_custom_sq # skip upstream tables if the source is postgres and the database is not whitelisted if table.get(tableau_constant.CONNECTION_TYPE) == "postgres": - upstream_db = ( - table[tableau_constant.DATABASE][tableau_constant.NAME] - if table.get(tableau_constant.DATABASE) - and table[tableau_constant.DATABASE].get(tableau_constant.NAME) - else "" - ) + upstream_db = table.get([tableau_constant.DATABASE], {}).get([tableau_constant.NAME], "") if ( upstream_db and upstream_db not in self.upstream_postgres_database_whitelist