Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ingest): bump sqlglot dep #10144

Merged
merged 3 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
sqlglot_lib = {
# Using an Acryl fork of sqlglot.
# https://github.com/tobymao/sqlglot/compare/main...hsheth2:sqlglot:hsheth?expand=1
"acryl-sqlglot==22.4.1.dev4",
"acryl-sqlglot==23.2.1.dev5",
}

classification_lib = {
Expand Down
8 changes: 5 additions & 3 deletions metadata-ingestion/src/datahub/sql_parsing/sqlglot_lineage.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import sqlglot
import sqlglot.errors
import sqlglot.lineage
import sqlglot.optimizer
import sqlglot.optimizer.annotate_types
import sqlglot.optimizer.optimizer
import sqlglot.optimizer.qualify
Expand Down Expand Up @@ -479,6 +480,8 @@ def _schema_aware_fuzzy_column_resolve(
try:
assert isinstance(statement, _SupportedColumnLineageTypesTuple)

cached_scope = sqlglot.optimizer.build_scope(statement)

# List output columns.
output_columns = [
(select_col.alias_or_name, select_col) for select_col in statement.selects
Expand All @@ -505,6 +508,8 @@ def _schema_aware_fuzzy_column_resolve(
statement,
dialect=dialect,
schema=sqlglot_db_schema,
scope=cached_scope,
trim_selects=False,
)
# pathlib.Path("sqlglot.html").write_text(
# str(lineage_node.to_html(dialect=dialect))
Expand All @@ -529,9 +534,6 @@ def _schema_aware_fuzzy_column_resolve(

# Parse the column name out of the node name.
# Sqlglot calls .sql(), so we have to do the inverse.
if node.name == "*":
continue

normalized_col = sqlglot.parse_one(node.name).this.name
if node.subfield:
normalized_col = f"{normalized_col}.{node.subfield}"
Expand Down
Loading