Skip to content

Commit

Permalink
reverting last 4 commits
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajasekhar-Vuppala committed May 31, 2024
1 parent 6f735ec commit 702d1d4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion test/sample_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
]

sample_view_columns = [
'annual_income',
'SUM',
'customer_state'

]
Expand Down
5 changes: 2 additions & 3 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def vconn():
yield [engine, conn]
except:
print("Failed to connect to the database")

conn.close()
engine.dispose()

Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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

Expand Down
21 changes: 10 additions & 11 deletions vertica_sqlalchemy_dialect/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
)
)
Expand All @@ -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"],
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 702d1d4

Please sign in to comment.