Skip to content

Commit 4f06133

Browse files
committed
Filter snapshots in Plan.environment
1 parent 1893f6e commit 4f06133

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

sqlmesh/core/plan/definition.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,14 @@ def environment(self) -> Environment:
185185

186186
snapshots_by_name = self.context_diff.snapshots_by_name
187187
snapshots = [s.table_info for s in self.snapshots.values()]
188-
promoted_snapshot_ids = None
188+
189+
# only promote snapshots with virtual layer views
190+
promoted_snapshot_ids = [
191+
s.snapshot_id
192+
for s in snapshots
193+
if s.is_model and s.model_kind_name and not s.model_kind_name.is_symbolic
194+
]
195+
189196
if self.is_dev and not self.include_unmodified:
190197
if self.selected_models_to_backfill is not None:
191198
# Only promote models that have been explicitly selected for backfill.
@@ -201,7 +208,7 @@ def environment(self) -> Environment:
201208
promotable_snapshot_ids = self.context_diff.promotable_snapshot_ids.copy()
202209

203210
promoted_snapshot_ids = [
204-
s.snapshot_id for s in snapshots if s.snapshot_id in promotable_snapshot_ids
211+
id for id in promoted_snapshot_ids if id in promotable_snapshot_ids
205212
]
206213

207214
previous_finalized_snapshots = (

sqlmesh/core/plan/evaluator.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,7 @@ def _demote_snapshots(
438438
on_complete: t.Optional[t.Callable[[SnapshotInfoLike], None]] = None,
439439
) -> None:
440440
self.snapshot_evaluator.demote(
441-
target_snapshots,
442-
environment_naming_info,
443-
on_complete=on_complete,
441+
target_snapshots, environment_naming_info, on_complete=on_complete
444442
)
445443

446444
def _restate(self, plan: EvaluatablePlan, snapshots_by_name: t.Dict[str, Snapshot]) -> None:

0 commit comments

Comments
 (0)