Skip to content

Commit eb174fd

Browse files
authored
Chore: Add metadata_updated_snapshots to EvaluatablePlan (#4796)
1 parent 1e1ace1 commit eb174fd

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

sqlmesh/core/plan/definition.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ def to_evaluatable(self) -> EvaluatablePlan:
261261
indirectly_modified_snapshots={
262262
s.name: sorted(snapshot_ids) for s, snapshot_ids in self.indirectly_modified.items()
263263
},
264+
metadata_updated_snapshots=sorted(self.metadata_updated),
264265
removed_snapshots=sorted(self.context_diff.removed_snapshots),
265266
requires_backfill=self.requires_backfill,
266267
models_to_backfill=self.models_to_backfill,
@@ -298,6 +299,7 @@ class EvaluatablePlan(PydanticModel):
298299
ensure_finalized_snapshots: bool
299300
directly_modified_snapshots: t.List[SnapshotId]
300301
indirectly_modified_snapshots: t.Dict[str, t.List[SnapshotId]]
302+
metadata_updated_snapshots: t.List[SnapshotId]
301303
removed_snapshots: t.List[SnapshotId]
302304
requires_backfill: bool
303305
models_to_backfill: t.Optional[t.Set[str]] = None

tests/core/test_plan_stages.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ def test_build_plan_stages_basic(
108108
ensure_finalized_snapshots=False,
109109
directly_modified_snapshots=[snapshot_a.snapshot_id, snapshot_b.snapshot_id],
110110
indirectly_modified_snapshots={},
111+
metadata_updated_snapshots=[],
111112
removed_snapshots=[],
112113
requires_backfill=True,
113114
models_to_backfill=None,
@@ -215,6 +216,7 @@ def test_build_plan_stages_with_before_all_and_after_all(
215216
ensure_finalized_snapshots=False,
216217
directly_modified_snapshots=[snapshot_a.snapshot_id, snapshot_b.snapshot_id],
217218
indirectly_modified_snapshots={},
219+
metadata_updated_snapshots=[],
218220
removed_snapshots=[],
219221
requires_backfill=True,
220222
models_to_backfill=None,
@@ -323,6 +325,7 @@ def test_build_plan_stages_select_models(
323325
ensure_finalized_snapshots=False,
324326
directly_modified_snapshots=[snapshot_a.snapshot_id, snapshot_b.snapshot_id],
325327
indirectly_modified_snapshots={},
328+
metadata_updated_snapshots=[],
326329
removed_snapshots=[],
327330
requires_backfill=True,
328331
models_to_backfill={snapshot_a.name},
@@ -422,6 +425,7 @@ def test_build_plan_stages_basic_no_backfill(
422425
ensure_finalized_snapshots=False,
423426
directly_modified_snapshots=[snapshot_a.snapshot_id, snapshot_b.snapshot_id],
424427
indirectly_modified_snapshots={},
428+
metadata_updated_snapshots=[],
425429
removed_snapshots=[],
426430
requires_backfill=True,
427431
models_to_backfill=None,
@@ -531,6 +535,7 @@ def test_build_plan_stages_restatement(
531535
ensure_finalized_snapshots=False,
532536
directly_modified_snapshots=[], # No changes
533537
indirectly_modified_snapshots={}, # No changes
538+
metadata_updated_snapshots=[],
534539
removed_snapshots=[],
535540
requires_backfill=True,
536541
models_to_backfill=None,
@@ -642,6 +647,7 @@ def test_build_plan_stages_forward_only(
642647
indirectly_modified_snapshots={
643648
new_snapshot_a.name: [new_snapshot_b.snapshot_id],
644649
},
650+
metadata_updated_snapshots=[],
645651
removed_snapshots=[],
646652
requires_backfill=True,
647653
models_to_backfill=None,
@@ -770,6 +776,7 @@ def test_build_plan_stages_forward_only_dev(
770776
indirectly_modified_snapshots={
771777
new_snapshot_a.name: [new_snapshot_b.snapshot_id],
772778
},
779+
metadata_updated_snapshots=[],
773780
removed_snapshots=[],
774781
requires_backfill=True,
775782
models_to_backfill=None,
@@ -893,6 +900,7 @@ def _get_snapshots(snapshot_ids: t.List[SnapshotId]) -> t.Dict[SnapshotId, Snaps
893900
indirectly_modified_snapshots={
894901
new_snapshot_a.name: [new_snapshot_b.snapshot_id],
895902
},
903+
metadata_updated_snapshots=[],
896904
removed_snapshots=[],
897905
requires_backfill=True,
898906
models_to_backfill=None,
@@ -1016,6 +1024,7 @@ def test_build_plan_stages_forward_only_ensure_finalized_snapshots(
10161024
indirectly_modified_snapshots={
10171025
new_snapshot_a.name: [new_snapshot_b.snapshot_id],
10181026
},
1027+
metadata_updated_snapshots=[],
10191028
removed_snapshots=[],
10201029
requires_backfill=True,
10211030
models_to_backfill=None,
@@ -1088,6 +1097,7 @@ def test_build_plan_stages_removed_model(
10881097
ensure_finalized_snapshots=False,
10891098
directly_modified_snapshots=[],
10901099
indirectly_modified_snapshots={},
1100+
metadata_updated_snapshots=[],
10911101
removed_snapshots=[snapshot_b.snapshot_id],
10921102
requires_backfill=False,
10931103
models_to_backfill=None,
@@ -1169,6 +1179,7 @@ def test_build_plan_stages_environment_suffix_target_changed(
11691179
ensure_finalized_snapshots=False,
11701180
directly_modified_snapshots=[],
11711181
indirectly_modified_snapshots={},
1182+
metadata_updated_snapshots=[],
11721183
removed_snapshots=[],
11731184
requires_backfill=False,
11741185
models_to_backfill=None,
@@ -1268,6 +1279,7 @@ def test_build_plan_stages_indirect_non_breaking_no_migration(
12681279
indirectly_modified_snapshots={
12691280
new_snapshot_a.name: [new_snapshot_b.snapshot_id],
12701281
},
1282+
metadata_updated_snapshots=[],
12711283
removed_snapshots=[],
12721284
requires_backfill=True,
12731285
models_to_backfill=None,
@@ -1355,6 +1367,7 @@ def test_build_plan_stages_indirect_non_breaking_view_migration(
13551367
indirectly_modified_snapshots={
13561368
new_snapshot_a.name: [new_snapshot_c.snapshot_id],
13571369
},
1370+
metadata_updated_snapshots=[],
13581371
removed_snapshots=[],
13591372
requires_backfill=True,
13601373
models_to_backfill=None,

0 commit comments

Comments
 (0)