Skip to content

Commit f83d29e

Browse files
committed
Ensured that representative but non-deployable snapshots are not created.
Signed-off-by: davem-bis <68955845+davem-bis@users.noreply.github.com>
1 parent b880f77 commit f83d29e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎sqlmesh/core/plan/stages.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def build(self, plan: EvaluatablePlan) -> t.List[PlanStage]:
313313
if plan.new_snapshots:
314314
stages.append(CreateSnapshotRecordsStage(snapshots=plan.new_snapshots))
315315

316-
snapshots_to_create = self._get_snapshots_to_create(plan, snapshots)
316+
snapshots_to_create = self._get_snapshots_to_create(plan, snapshots, deployability_index)
317317
if snapshots_to_create:
318318
stages.append(
319319
PhysicalLayerSchemaCreationStage(
@@ -629,7 +629,7 @@ def _get_audit_only_snapshots(
629629
return audit_snapshots
630630

631631
def _get_snapshots_to_create(
632-
self, plan: EvaluatablePlan, snapshots: t.Dict[SnapshotId, Snapshot]
632+
self, plan: EvaluatablePlan, snapshots: t.Dict[SnapshotId, Snapshot], deployability_index: DeployabilityIndex
633633
) -> t.List[Snapshot]:
634634
promoted_snapshot_ids = (
635635
set(plan.environment.promoted_snapshot_ids)
@@ -640,6 +640,11 @@ def _get_snapshots_to_create(
640640
def _should_create(s: Snapshot) -> bool:
641641
if not s.is_model or s.is_symbolic:
642642
return False
643+
644+
# Do not create snapshots that contain production data but can never be deployed.
645+
if deployability_index.is_representative(s) and not deployability_index.is_deployable(s):
646+
return False
647+
643648
# Only create tables for snapshots that we're planning to promote or that were selected for backfill
644649
return (
645650
plan.is_selected_for_backfill(s.name)

0 commit comments

Comments
 (0)