Skip to content

Commit 6d190f0

Browse files
Address Copilot review: Fix multi-table column lineage fallback and correct pytest ordering
1 parent 37739a4 commit 6d190f0

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

ingestion/tests/unit/topology/dashboard/test_quicksight.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,49 @@ def test_build_column_lineage_from_parser_multi_table_filters_correctly(self):
482482
assert result[0].fromColumns == [src_fqn]
483483
assert result[0].toColumn == alias_fqn
484484

485+
@pytest.mark.order(11)
486+
def test_build_column_lineage_no_fallback_when_parser_has_global_lineage(self):
487+
"""
488+
Regression test for the multi-table fallback bug (Issue #26670).
489+
490+
When lineage_parser.column_lineage is non-empty (parser succeeded)
491+
but none of the pairs match from_entity (because they belong to a
492+
different upstream table in a multi-table JOIN), the method must
493+
return an empty list and must NOT call _get_column_lineage (the
494+
name-based fallback). Calling the fallback here would manufacture
495+
incorrect cross-table column lineage.
496+
"""
497+
# Parser found lineage for a DIFFERENT table, not our from_entity
498+
other_src_col = MagicMock()
499+
other_src_col.raw_name = "user_id"
500+
other_src_col._parent = MagicMock()
501+
other_src_col._parent.__str__ = MagicMock(return_value="users_table")
502+
503+
other_tgt_col = MagicMock()
504+
other_tgt_col.raw_name = "uid"
505+
506+
mock_parser = MagicMock()
507+
# Parser globally found lineage — but only for 'users_table'
508+
mock_parser.column_lineage = [(other_src_col, other_tgt_col)]
509+
510+
mock_from_entity = MagicMock()
511+
# Our from_entity is 'orders_table' — no parser pairs match it
512+
mock_from_entity.name.root = "orders_table"
513+
mock_data_model = MagicMock()
514+
515+
with patch.object(
516+
self.quicksight,
517+
"_get_column_lineage",
518+
) as mock_fallback:
519+
result = self.quicksight._build_column_lineage_from_parser(
520+
mock_parser, mock_from_entity, mock_data_model
521+
)
522+
523+
# Must NOT have called the name-based fallback
524+
mock_fallback.assert_not_called()
525+
# Must return an empty list — no manufactured lineage
526+
assert result == []
527+
485528
@pytest.mark.order(12)
486529
def test_build_column_lineage_no_fallback_when_parser_has_global_lineage(self):
487530
"""

0 commit comments

Comments
 (0)