@@ -93,10 +93,18 @@ def _push(self, plan: Plan) -> None:
9393 Args:
9494 plan: The plan to source snapshots from.
9595 """
96- snapshots = {snapshot .name : snapshot for snapshot in plan .new_snapshots }
97- self .state_sync .push_snapshots (snapshots .values ())
98- for snapshot in snapshots .values ():
99- self .snapshot_evaluator .create (snapshot , snapshots )
96+ parent_snapshot_ids = {
97+ p_sid for snapshot in plan .new_snapshots for p_sid in snapshot .parents
98+ }
99+
100+ stored_snapshots_by_id = self .state_sync .get_snapshots (parent_snapshot_ids )
101+ new_snapshots_by_id = {
102+ snapshot .snapshot_id : snapshot for snapshot in plan .new_snapshots
103+ }
104+ all_snapshots_by_id = {** stored_snapshots_by_id , ** new_snapshots_by_id }
105+
106+ self .snapshot_evaluator .create (plan .new_snapshots , all_snapshots_by_id )
107+ self .state_sync .push_snapshots (plan .new_snapshots )
100108
101109 def _promote (self , plan : Plan ) -> None :
102110 """Promote a plan.
@@ -110,16 +118,14 @@ def _promote(self, plan: Plan) -> None:
110118
111119 added , removed = self .state_sync .promote (environment , no_gaps = plan .no_gaps )
112120
113- for snapshot_table_info in added :
114- self .snapshot_evaluator .promote (
115- snapshot_table_info ,
116- environment = environment .name ,
117- )
118- for snapshot_table_info in removed :
119- self .snapshot_evaluator .demote (
120- snapshot_table_info ,
121- environment = environment .name ,
122- )
121+ self .snapshot_evaluator .promote (
122+ added ,
123+ environment = environment .name ,
124+ )
125+ self .snapshot_evaluator .demote (
126+ removed ,
127+ environment = environment .name ,
128+ )
123129
124130
125131class AirflowPlanEvaluator (PlanEvaluator ):
@@ -132,6 +138,7 @@ def __init__(
132138 dag_creation_poll_interval_secs : int = 30 ,
133139 dag_creation_max_retry_attempts : int = 10 ,
134140 notification_targets : t .Optional [t .List [NotificationTarget ]] = None ,
141+ ddl_concurrent_tasks : int = 1 ,
135142 ):
136143 self .airflow_client = airflow_client
137144 self .blocking = blocking
@@ -140,6 +147,7 @@ def __init__(
140147 self .dag_creation_max_retry_attempts = dag_creation_max_retry_attempts
141148 self .console = console or get_console ()
142149 self .notification_targets = notification_targets or []
150+ self .ddl_concurrent_tasks = ddl_concurrent_tasks
143151
144152 def evaluate (self , plan : Plan ) -> None :
145153 environment = plan .environment
@@ -153,6 +161,7 @@ def evaluate(self, plan: Plan) -> None:
153161 no_gaps = plan .no_gaps ,
154162 restatements = plan .restatements ,
155163 notification_targets = self .notification_targets ,
164+ ddl_concurrent_tasks = self .ddl_concurrent_tasks ,
156165 )
157166
158167 if self .blocking :
0 commit comments