@@ -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.
@@ -249,6 +250,7 @@ def promote(
249250 environment_naming_info = environment_naming_info ,
250251 deployability_index = deployability_index , # type: ignore
251252 on_complete = on_complete ,
253+ snapshots_with_virtual_views = snapshots_with_virtual_views ,
252254 ),
253255 self .ddl_concurrent_tasks ,
254256 )
@@ -258,6 +260,7 @@ def demote(
258260 target_snapshots : t .Iterable [SnapshotInfoLike ],
259261 environment_naming_info : EnvironmentNamingInfo ,
260262 on_complete : t .Optional [t .Callable [[SnapshotInfoLike ], None ]] = None ,
263+ snapshots_with_virtual_views : t .Optional [t .List [SnapshotId ]] = None ,
261264 ) -> None :
262265 """Demotes the given collection of snapshots in the target environment by removing its view.
263266
@@ -269,7 +272,9 @@ def demote(
269272 with self .concurrent_context ():
270273 concurrent_apply_to_snapshots (
271274 target_snapshots ,
272- lambda s : self ._demote_snapshot (s , environment_naming_info , on_complete ),
275+ lambda s : self ._demote_snapshot (
276+ s , environment_naming_info , on_complete , snapshots_with_virtual_views
277+ ),
273278 self .ddl_concurrent_tasks ,
274279 )
275280
@@ -918,6 +923,7 @@ def _promote_snapshot(
918923 execution_time : t .Optional [TimeLike ] = None ,
919924 snapshots : t .Optional [t .Dict [SnapshotId , Snapshot ]] = None ,
920925 table_mapping : t .Optional [t .Dict [str , str ]] = None ,
926+ snapshots_with_virtual_views : t .Optional [t .List [SnapshotId ]] = None ,
921927 ) -> None :
922928 if snapshot .is_model :
923929 adapter = self .adapter
@@ -944,22 +950,31 @@ def _promote_snapshot(
944950 )
945951 adapter .execute (snapshot .model .render_on_virtual_update (** render_kwargs ))
946952
947- if on_complete is not None :
953+ if (
954+ on_complete is not None
955+ and snapshots_with_virtual_views
956+ and snapshot .snapshot_id in snapshots_with_virtual_views
957+ ):
948958 on_complete (snapshot )
949959
950960 def _demote_snapshot (
951961 self ,
952962 snapshot : SnapshotInfoLike ,
953963 environment_naming_info : EnvironmentNamingInfo ,
954964 on_complete : t .Optional [t .Callable [[SnapshotInfoLike ], None ]],
965+ snapshots_with_virtual_views : t .Optional [t .List [SnapshotId ]] = None ,
955966 ) -> None :
956967 adapter = self .adapter
957968 view_name = snapshot .qualified_view_name .for_environment (
958969 environment_naming_info , dialect = adapter .dialect
959970 )
960971 _evaluation_strategy (snapshot , adapter ).demote (view_name )
961972
962- if on_complete is not None :
973+ if (
974+ on_complete is not None
975+ and snapshots_with_virtual_views
976+ and snapshot .snapshot_id in snapshots_with_virtual_views
977+ ):
963978 on_complete (snapshot )
964979
965980 def _cleanup_snapshot (
0 commit comments