@@ -216,6 +216,7 @@ def promote(
216216 snapshots : t .Optional [t .Dict [SnapshotId , Snapshot ]] = None ,
217217 table_mapping : t .Optional [t .Dict [str , str ]] = None ,
218218 on_complete : t .Optional [t .Callable [[SnapshotInfoLike ], None ]] = None ,
219+ snapshots_with_virtual_views : t .Optional [t .List [SnapshotId ]] = None ,
219220 ) -> None :
220221 """Promotes the given collection of snapshots in the target environment by replacing a corresponding
221222 view with a physical table associated with the given snapshot.
@@ -257,6 +258,7 @@ def promote(
257258 environment_naming_info = environment_naming_info ,
258259 deployability_index = deployability_index , # type: ignore
259260 on_complete = on_complete ,
261+ snapshots_with_virtual_views = snapshots_with_virtual_views ,
260262 ),
261263 self .ddl_concurrent_tasks ,
262264 )
@@ -266,6 +268,7 @@ def demote(
266268 target_snapshots : t .Iterable [SnapshotInfoLike ],
267269 environment_naming_info : EnvironmentNamingInfo ,
268270 on_complete : t .Optional [t .Callable [[SnapshotInfoLike ], None ]] = None ,
271+ snapshots_with_virtual_views : t .Optional [t .List [SnapshotId ]] = None ,
269272 ) -> None :
270273 """Demotes the given collection of snapshots in the target environment by removing its view.
271274
@@ -277,7 +280,9 @@ def demote(
277280 with self .concurrent_context ():
278281 concurrent_apply_to_snapshots (
279282 target_snapshots ,
280- lambda s : self ._demote_snapshot (s , environment_naming_info , on_complete ),
283+ lambda s : self ._demote_snapshot (
284+ s , environment_naming_info , on_complete , snapshots_with_virtual_views
285+ ),
281286 self .ddl_concurrent_tasks ,
282287 )
283288
@@ -943,6 +948,7 @@ def _promote_snapshot(
943948 execution_time : t .Optional [TimeLike ] = None ,
944949 snapshots : t .Optional [t .Dict [SnapshotId , Snapshot ]] = None ,
945950 table_mapping : t .Optional [t .Dict [str , str ]] = None ,
951+ snapshots_with_virtual_views : t .Optional [t .List [SnapshotId ]] = None ,
946952 ) -> None :
947953 if snapshot .is_model :
948954 adapter = (
@@ -973,14 +979,19 @@ def _promote_snapshot(
973979 )
974980 adapter .execute (snapshot .model .render_on_virtual_update (** render_kwargs ))
975981
976- if on_complete is not None :
982+ if (
983+ on_complete is not None
984+ and snapshots_with_virtual_views
985+ and snapshot .snapshot_id in snapshots_with_virtual_views
986+ ):
977987 on_complete (snapshot )
978988
979989 def _demote_snapshot (
980990 self ,
981991 snapshot : SnapshotInfoLike ,
982992 environment_naming_info : EnvironmentNamingInfo ,
983993 on_complete : t .Optional [t .Callable [[SnapshotInfoLike ], None ]],
994+ snapshots_with_virtual_views : t .Optional [t .List [SnapshotId ]] = None ,
984995 ) -> None :
985996 adapter = (
986997 self .get_adapter (snapshot .model_gateway )
@@ -992,7 +1003,11 @@ def _demote_snapshot(
9921003 )
9931004 _evaluation_strategy (snapshot , adapter ).demote (view_name )
9941005
995- if on_complete is not None :
1006+ if (
1007+ on_complete is not None
1008+ and snapshots_with_virtual_views
1009+ and snapshot .snapshot_id in snapshots_with_virtual_views
1010+ ):
9961011 on_complete (snapshot )
9971012
9981013 def _cleanup_snapshot (
0 commit comments