From 702d1d4bb4b6ed0ad15985415d4add043c8aa523 Mon Sep 17 00:00:00 2001 From: Rajasekhar-Vuppala Date: Fri, 31 May 2024 11:48:12 +0530 Subject: [PATCH] reverting last 4 commits --- test/sample_objects.py | 2 +- test/test_integration.py | 5 ++--- vertica_sqlalchemy_dialect/base.py | 21 ++++++++++----------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/test/sample_objects.py b/test/sample_objects.py index 343d6d5..b82c861 100644 --- a/test/sample_objects.py +++ b/test/sample_objects.py @@ -130,7 +130,7 @@ ] sample_view_columns = [ - 'annual_income', + 'SUM', 'customer_state' ] diff --git a/test/test_integration.py b/test/test_integration.py index 3076fc4..000dbd9 100644 --- a/test/test_integration.py +++ b/test/test_integration.py @@ -30,7 +30,7 @@ def vconn(): yield [engine, conn] except: print("Failed to connect to the database") - + conn.close() engine.dispose() @@ -255,7 +255,6 @@ def test_get_all_view_columns(vconn): assert len(res)>0 # Assert sample columns assert all(value["name"] in sample.sample_view_columns for value in res) - def test_get_view_comment(vconn): @@ -295,7 +294,7 @@ def test_get_all_projection_columns(vconn): def test__populate_view_lineage(vconn): res = vconn[0].dialect._populate_view_lineage(connection=vconn[1], view=sample.sample_view ,schema="public") - upstream = "VMart.public.customer_dimension" + upstream = "public.customer_dimension" downstream = next(iter(res.keys())) assert res[downstream][0][0] == upstream diff --git a/vertica_sqlalchemy_dialect/base.py b/vertica_sqlalchemy_dialect/base.py index 48de330..b38d544 100644 --- a/vertica_sqlalchemy_dialect/base.py +++ b/vertica_sqlalchemy_dialect/base.py @@ -761,7 +761,7 @@ def get_table_names(self, connection, schema=None, **kw): get_tables_sql = sql.text( dedent( """ - SELECT lower(table_name) as table_name + SELECT table_name FROM v_catalog.tables WHERE %(schema_condition)s ORDER BY table_schema, table_name @@ -810,10 +810,10 @@ def get_view_names(self, connection, schema=None, **kw): get_views_sql = sql.text( dedent( """ - SELECT lower(table_name) as table_name + SELECT table_name FROM v_catalog.views WHERE %(schema_condition)s - ORDER BY table_schema, lower(table_name) + ORDER BY table_schema, table_name """ % {"schema_condition": schema_condition} ) @@ -847,7 +847,7 @@ def fetch_view_definitions(self, connection,schema): for data in connection.execute(view_def): definition.append({ "view_def": data['VIEW_DEFINITION'], - "table_name": data['table_name'].lower() + "table_name": data['table_name'] }) return definition @@ -902,7 +902,7 @@ def fetch_table_columns(self, connection, schema): columns = [] for row in connection.execute(s): - name = row.column_name.lower() + name = row.column_name dtype = row.data_type.lower() default = row.column_default nullable = row.is_nullable @@ -1928,7 +1928,7 @@ def fetch_view_columns(self, connection, schema): columns = [] for row in connection.execute(s): - name = row.column_name.lower() + name = row.column_name dtype = row.data_type.lower() default = row.column_default nullable = row.is_nullable @@ -2052,7 +2052,7 @@ def fetch_view_lineage(self, connection,schema) -> None: view_upstream_lineage_query = sql.text( dedent( """ - select (select database_name from v_catalog.databases) database_name,table_name ,table_schema, reference_table_name ,reference_table_schema from v_catalog.view_tables where table_schema = '%(schema)s' """ + select table_name ,table_schema, reference_table_name ,reference_table_schema from v_catalog.view_tables where table_schema = '%(schema)s' """ % {"schema": schema} ) ) @@ -2061,8 +2061,7 @@ def fetch_view_lineage(self, connection,schema) -> None: for data in connection.execute(view_upstream_lineage_query): # refrence_table.append(data) refrence_table.append( - { - "database_name": data["database_name"], + { "reference_table_name": data["reference_table_name"], "reference_table_schema": data["reference_table_schema"], "view_name": data["table_name"], @@ -2095,9 +2094,9 @@ def _populate_view_lineage(self, connection, view, schema: str) -> None: for lineage in refrence_table: - downstream = f"{lineage['database_name']}.{lineage['table_schema']}.{lineage['view_name']}" + downstream = f"{lineage['table_schema']}.{lineage['view_name']}" - upstream = f"{lineage['database_name']}.{lineage['reference_table_schema']}.{lineage['reference_table_name']}" + upstream = f"{lineage['reference_table_schema']}.{lineage['reference_table_name']}" view_upstream: str = upstream view_name: str = downstream