1010from sqlmesh .core .dialect import schema_
1111from sqlmesh .core .environment import Environment
1212from sqlmesh .core .snapshot import (
13- DeployabilityIndex ,
1413 Snapshot ,
1514 SnapshotId ,
1615 SnapshotIdLike ,
@@ -100,17 +99,16 @@ def get_environment(self, environment: str) -> t.Optional[Environment]:
10099 def promote (
101100 self ,
102101 environment : Environment ,
103- deployability_index : t .Optional [DeployabilityIndex ] = None ,
104- no_gaps : bool = False ,
102+ no_gaps_snapshot_names : t .Optional [t .Set [str ]] = None ,
105103 ) -> PromotionResult :
106104 """Update the environment to reflect the current state.
107105
108106 This method verifies that snapshots have been pushed.
109107
110108 Args:
111109 environment: The environment to promote.
112- deployability_index: Determines snapshots that are deployable in the context of this promotion.
113- no_gaps: Whether to ensure that new snapshots for models that are already a
110+ no_gaps_snapshot_names: A set of snapshot names to check for data gaps. If None,
111+ all snapshots will be checked. The data gap check ensures that models that are already a
114112 part of the target environment have no data gaps when compared against previous
115113 snapshots for same models.
116114
@@ -144,12 +142,12 @@ def promote(
144142 "Please recreate the plan and try again"
145143 )
146144
147- if no_gaps :
145+ if no_gaps_snapshot_names != set () :
148146 snapshots = self ._get_snapshots (environment .snapshots ).values ()
149147 self ._ensure_no_gaps (
150148 snapshots ,
151149 existing_environment ,
152- deployability_index or DeployabilityIndex . all_deployable () ,
150+ no_gaps_snapshot_names ,
153151 )
154152
155153 existing_table_infos = {
@@ -295,7 +293,7 @@ def _ensure_no_gaps(
295293 self ,
296294 target_snapshots : t .Iterable [Snapshot ],
297295 target_environment : Environment ,
298- deployability_index : DeployabilityIndex ,
296+ snapshot_names : t . Optional [ t . Set [ str ]] ,
299297 ) -> None :
300298 target_snapshots_by_name = {s .name : s for s in target_snapshots }
301299
@@ -314,7 +312,7 @@ def _ensure_no_gaps(
314312 for prev_snapshot in prev_snapshots :
315313 target_snapshot = target_snapshots_by_name [prev_snapshot .name ]
316314 if (
317- deployability_index . is_representative ( target_snapshot )
315+ ( snapshot_names is None or prev_snapshot . name in snapshot_names )
318316 and target_snapshot .is_incremental
319317 and prev_snapshot .is_incremental
320318 and prev_snapshot .intervals
0 commit comments