You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from sql_metadata import Parser
sql = """
select
dependent_schema.name as dependent_schema,
relationships.dependent_name as dependent_name
from relationships
join schema as dependent_schema on relationships.dependent_schema_id=dependent_schema.id
join schema as referenced_schema on relationships.referenced_schema_id=referenced_schema.id
group by dependent_schema, dependent_name
order by dependent_schema, dependent_name;
"""
parser = Parser(sql)
print(parser.tables)
print(parser.columns)
print(parser.columns_dict)
produces the following error:
['relationships', 'schema']
Traceback (most recent call last):
File "/Users/giacomochiarella/github/dwh_dbt/fake_dataset.py", line 83, in <module>
print(parser.columns)
File "/Users/giacomochiarella/github/dwh_dbt/venv/lib/python3.9/site-packages/sql_metadata/parser.py", line 202, in columns
columns_aliases_names=self.columns_aliases_names,
File "/Users/giacomochiarella/github/dwh_dbt/venv/lib/python3.9/site-packages/sql_metadata/parser.py", line 326, in columns_aliases_names
self._handle_column_alias_subquery_level_update(token=token)
File "/Users/giacomochiarella/github/dwh_dbt/venv/lib/python3.9/site-packages/sql_metadata/parser.py", line 674, in _handle_column_alias_subquery_level_update
self._add_to_columns_aliases_subsection(token=token)
File "/Users/giacomochiarella/github/dwh_dbt/venv/lib/python3.9/site-packages/sql_metadata/parser.py", line 740, in _add_to_columns_aliases_subsection
section = COLUMNS_SECTIONS[keyword]
KeyError: 'JOIN'
if I comment the first selected column (dependent_schema.name as dependent_schema,) or I comment the first join (join schema as dependent_schema on relationships.dependent_schema_id=dependent_schema.id) I don't get any error.
I know the query does make much sense, but the sql code should be syntactically correct. Anyone can help me?
The text was updated successfully, but these errors were encountered:
Using the following code:
produces the following error:
if I comment the first selected column (
dependent_schema.name as dependent_schema,
) or I comment the first join (join schema as dependent_schema on relationships.dependent_schema_id=dependent_schema.id
) I don't get any error.I know the query does make much sense, but the sql code should be syntactically correct. Anyone can help me?
The text was updated successfully, but these errors were encountered: