Skip to content

Commit 35e34d5

Browse files
authored
Fix: Detection of broken model references when building a plan (#2390)
1 parent b274a54 commit 35e34d5

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

sqlmesh/core/plan/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def _ensure_no_forward_only_revert(self) -> None:
615615
def _ensure_no_broken_references(self) -> None:
616616
for snapshot in self._context_diff.snapshots.values():
617617
broken_references = {x.name for x in self._context_diff.removed_snapshots} & {
618-
x.name for x in snapshot.parents
618+
x for x in snapshot.node.depends_on
619619
}
620620
if broken_references:
621621
broken_references_msg = ", ".join(f"'{x}'" for x in broken_references)

tests/core/test_plan.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -668,9 +668,7 @@ def test_broken_references(make_snapshot, mocker: MockerFixture):
668668
snapshot_a = make_snapshot(SqlModel(name="a", query=parse_one("select 1, ds")))
669669
snapshot_a.categorize_as(SnapshotChangeCategory.BREAKING)
670670

671-
snapshot_b = make_snapshot(
672-
SqlModel(name="b", query=parse_one("select 2, ds FROM a")), nodes={'"a"': snapshot_a.node}
673-
)
671+
snapshot_b = make_snapshot(SqlModel(name="b", query=parse_one("select 2, ds FROM a")))
674672
snapshot_b.categorize_as(SnapshotChangeCategory.BREAKING)
675673

676674
context_diff = ContextDiff(

0 commit comments

Comments
 (0)