Skip to content

Commit

Permalink
Don't use database as fallback when no schema parsed. (#32959)
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Dardzinski <[email protected]>
  • Loading branch information
JDarDagran authored Aug 1, 2023
1 parent 9b7ed43 commit 2a39914
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion airflow/providers/openlineage/sqlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,6 @@ def _get_tables_hierarchy(
else:
db = None
schemas = hierarchy.setdefault(normalize_name(db) if db else db, {})
tables = schemas.setdefault(normalize_name(table.schema) if table.schema else db, [])
tables = schemas.setdefault(normalize_name(table.schema) if table.schema else None, [])
tables.append(table.name)
return hierarchy
8 changes: 8 additions & 0 deletions tests/providers/openlineage/utils/test_sqlparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,14 @@ def test_get_tables_hierarchy(self):
is_cross_db=True,
) == {"db": {"schema1": ["Table2"]}, "db2": {"schema1": ["Table1"]}}

# cross db, no db & schema parsed
assert SQLParser._get_tables_hierarchy(
[DbTableMeta("Table1"), DbTableMeta("Table2")],
normalize_name_lower,
database="Db",
is_cross_db=True,
) == {"db": {None: ["Table1", "Table2"]}}

def test_normalize_sql(self):
assert SQLParser.normalize_sql("select * from asdf") == "select * from asdf"

Expand Down

0 comments on commit 2a39914

Please sign in to comment.