@@ -733,15 +733,7 @@ def _evaluate_snapshot(
733733 adapter .execute (model .render_pre_statements (** render_statements_kwargs ))
734734
735735 if not target_table_exists or (model .is_seed and not snapshot .intervals ):
736- if (
737- not is_snapshot_deployable
738- and snapshot .is_forward_only
739- and snapshot .is_materialized
740- and snapshot .previous_versions
741- and adapter .SUPPORTS_CLONING
742- # managed models cannot have their schema mutated because theyre based on queries, so clone + alter wont work
743- and not snapshot .is_managed
744- ):
736+ if self ._can_clone (snapshot , deployability_index ):
745737 self ._clone_snapshot_in_dev (
746738 snapshot = snapshot ,
747739 snapshots = snapshots ,
@@ -750,18 +742,17 @@ def _evaluate_snapshot(
750742 rendered_physical_properties = rendered_physical_properties ,
751743 allow_destructive_snapshots = allow_destructive_snapshots ,
752744 )
753- else :
754- if model .annotated or model .is_seed or model .kind .is_scd_type_2 :
755- self ._execute_create (
756- snapshot = snapshot ,
757- table_name = target_table_name ,
758- is_table_deployable = is_snapshot_deployable ,
759- deployability_index = deployability_index ,
760- create_render_kwargs = create_render_kwargs ,
761- rendered_physical_properties = rendered_physical_properties ,
762- dry_run = False ,
763- run_pre_post_statements = False ,
764- )
745+ elif model .annotated or model .is_seed or model .kind .is_scd_type_2 :
746+ self ._execute_create (
747+ snapshot = snapshot ,
748+ table_name = target_table_name ,
749+ is_table_deployable = is_snapshot_deployable ,
750+ deployability_index = deployability_index ,
751+ create_render_kwargs = create_render_kwargs ,
752+ rendered_physical_properties = rendered_physical_properties ,
753+ dry_run = False ,
754+ run_pre_post_statements = False ,
755+ )
765756
766757 wap_id : t .Optional [str ] = None
767758 if snapshot .is_materialized and (
@@ -808,6 +799,8 @@ def create_snapshot(
808799 if not snapshot .is_model :
809800 return
810801
802+ logger .info ("Creating a physical table for snapshot %s" , snapshot .snapshot_id )
803+
811804 adapter = self .get_adapter (snapshot .model .gateway )
812805 create_render_kwargs : t .Dict [str , t .Any ] = dict (
813806 engine_adapter = adapter ,
@@ -824,16 +817,7 @@ def create_snapshot(
824817 ** create_render_kwargs
825818 )
826819
827- if (
828- snapshot .is_forward_only
829- and snapshot .is_materialized
830- and snapshot .previous_versions
831- and adapter .SUPPORTS_CLONING
832- # managed models cannot have their schema mutated because theyre based on queries, so clone + alter wont work
833- and not snapshot .is_managed
834- # If the deployable table is missing we can't clone it
835- and not deployability_index .is_deployable (snapshot )
836- ):
820+ if self ._can_clone (snapshot , deployability_index ):
837821 self ._clone_snapshot_in_dev (
838822 snapshot = snapshot ,
839823 snapshots = snapshots ,
@@ -1370,6 +1354,19 @@ def _execute_create(
13701354 if run_pre_post_statements :
13711355 adapter .execute (snapshot .model .render_post_statements (** create_render_kwargs ))
13721356
1357+ def _can_clone (self , snapshot : Snapshot , deployability_index : DeployabilityIndex ) -> bool :
1358+ adapter = self .get_adapter (snapshot .model .gateway )
1359+ return (
1360+ snapshot .is_forward_only
1361+ and snapshot .is_materialized
1362+ and bool (snapshot .previous_versions )
1363+ and adapter .SUPPORTS_CLONING
1364+ # managed models cannot have their schema mutated because theyre based on queries, so clone + alter wont work
1365+ and not snapshot .is_managed
1366+ # If the deployable table is missing we can't clone it
1367+ and not deployability_index .is_deployable (snapshot )
1368+ )
1369+
13731370
13741371def _evaluation_strategy (snapshot : SnapshotInfoLike , adapter : EngineAdapter ) -> EvaluationStrategy :
13751372 klass : t .Type
0 commit comments