Skip to content

Commit 8df5e41

Browse files
committed
Fix: Support missing parents when constructing the deployability index (#2570)
1 parent 09b6318 commit 8df5e41

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

sqlmesh/core/snapshot/definition.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1211,7 +1211,7 @@ def _visit(node: SnapshotId, deployable: bool = True) -> None:
12111211
):
12121212
return
12131213

1214-
if deployable:
1214+
if deployable and node in snapshots:
12151215
snapshot = snapshots[node]
12161216
# Capture uncategorized snapshot which represents a forward-only model.
12171217
is_forward_only_model = (

tests/core/test_snapshot.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,20 @@ def test_deployability_index_uncategorized_forward_only_model(make_snapshot):
16011601
assert not deplyability_index.is_representative(snapshot_b)
16021602

16031603

1604+
def test_deployability_index_missing_parent(make_snapshot):
1605+
snapshot_a = make_snapshot(SqlModel(name="a", query=parse_one("SELECT 1")))
1606+
snapshot_a.categorize_as(SnapshotChangeCategory.BREAKING)
1607+
1608+
snapshot_b = make_snapshot(SqlModel(name="b", query=parse_one("SELECT 1")))
1609+
snapshot_b.categorize_as(SnapshotChangeCategory.FORWARD_ONLY)
1610+
snapshot_b.parents = (snapshot_a.snapshot_id,)
1611+
1612+
deplyability_index = DeployabilityIndex.create({snapshot_b.snapshot_id: snapshot_b})
1613+
1614+
assert not deplyability_index.is_deployable(snapshot_b)
1615+
assert not deplyability_index.is_deployable(snapshot_a)
1616+
1617+
16041618
@pytest.mark.parametrize(
16051619
"model_name, environment_naming_info, default_catalog, expected",
16061620
(

0 commit comments

Comments
 (0)