Skip to content

Commit

Permalink
fix(ingest/sqlglot): Make detach_ctes more robust (datahub-project#11449
Browse files Browse the repository at this point in the history
)
  • Loading branch information
asikowitz authored Sep 23, 2024
1 parent f1be366 commit 3c1dcf9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion metadata-ingestion/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
sqlglot_lib = {
# Using an Acryl fork of sqlglot.
# https://github.com/tobymao/sqlglot/compare/main...hsheth2:sqlglot:main?expand=1
"acryl-sqlglot[rs]==25.20.2.dev5",
"acryl-sqlglot[rs]==25.20.2.dev6",
}

classification_lib = {
Expand Down
3 changes: 3 additions & 0 deletions metadata-ingestion/src/datahub/sql_parsing/sqlglot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ def detach_ctes(
dialect = get_dialect(platform)
statement = parse_statement(sql, dialect=dialect)

if not cte_mapping:
return statement

def replace_cte_refs(node: sqlglot.exp.Expression) -> sqlglot.exp.Expression:
if (
isinstance(node, sqlglot.exp.Identifier)
Expand Down

0 comments on commit 3c1dcf9

Please sign in to comment.