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: del wildcard only with metadata_provider (#612) #640

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 4 additions & 2 deletions sqllineage/core/holders.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def expand_wildcard(self, metadata_provider: MetaDataProvider) -> None:
src_table_columns,
tgt_wildcard,
src_wildcard,
metadata_provider,
)

def get_alias_mapping_from_table_group(
Expand Down Expand Up @@ -227,6 +228,7 @@ def _replace_wildcard(
src_table_columns: List[Column],
tgt_wildcard: Column,
src_wildcard: Column,
metadata_provider: MetaDataProvider,
) -> None:
target_columns = self.get_table_columns(tgt_table)
for src_col in src_table_columns:
Expand All @@ -238,9 +240,9 @@ def _replace_wildcard(
self.graph.add_edge(src_col.parent, src_col, type=EdgeType.HAS_COLUMN)
self.graph.add_edge(src_col, new_column, type=EdgeType.LINEAGE)
# remove wildcard
if self.graph.has_node(tgt_wildcard):
if metadata_provider and self.graph.has_node(tgt_wildcard):
self.graph.remove_node(tgt_wildcard)
if self.graph.has_node(src_wildcard):
if metadata_provider and self.graph.has_node(src_wildcard):
self.graph.remove_node(src_wildcard)


Expand Down
26 changes: 26 additions & 0 deletions tests/sql/column/test_column_select_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ def test_select_column_wildcard():
)


# TODO
# Expected Lineage: {(Column: <default>.t2.f1, Column: <default>.result_table.f1), ...}
# Actual Lineage: {(Column: t2.f1, Column: <default>.result_table.f1), ...}

# def test_select_column_wildcard_with_fields():
# sql = """
# WITH t2 AS (SELECT * FROM t1),
# t3 AS (SELECT f1, * FROM t2)
# INSERT INTO result_table
# SELECT *
# FROM t3;"""
# assert_column_lineage_equal(
# sql,
# [
# (
# ColumnQualifierTuple("f1", "t2"),
# ColumnQualifierTuple("f1", "result_table"),
# ),
# (
# ColumnQualifierTuple("*", "t1"),
# ColumnQualifierTuple("*", "result_table"),
# ),
# ],
# )


def test_select_column_wildcard_with_qualifier():
sql = """INSERT INTO tab1
SELECT tab2.*
Expand Down
Loading