2828)
2929from sqlmesh .core .snapshot .definition import (
3030 Interval ,
31- SnapshotEvaluationTriggers ,
3231 SnapshotIntervals ,
3332 check_ready_intervals ,
3433 expand_range ,
@@ -228,7 +227,6 @@ def run(
228227 ignore_cron : bool = False ,
229228 end_bounded : bool = False ,
230229 selected_snapshots : t .Optional [t .Set [str ]] = None ,
231- selected_snapshots_auto_upstream : t .Optional [t .Set [str ]] = None ,
232230 circuit_breaker : t .Optional [t .Callable [[], bool ]] = None ,
233231 deployability_index : t .Optional [DeployabilityIndex ] = None ,
234232 auto_restatement_enabled : bool = False ,
@@ -245,7 +243,6 @@ def run(
245243 ignore_cron = ignore_cron ,
246244 end_bounded = end_bounded ,
247245 selected_snapshots = selected_snapshots ,
248- selected_snapshots_auto_upstream = selected_snapshots_auto_upstream ,
249246 circuit_breaker = circuit_breaker ,
250247 deployability_index = deployability_index ,
251248 auto_restatement_enabled = auto_restatement_enabled ,
@@ -381,7 +378,7 @@ def run_merged_intervals(
381378 run_environment_statements : bool = False ,
382379 audit_only : bool = False ,
383380 restatements : t .Optional [t .Dict [SnapshotId , Interval ]] = None ,
384- snapshot_evaluation_triggers : t .Dict [SnapshotId , SnapshotEvaluationTriggers ] = {},
381+ auto_restatement_triggers : t .Dict [SnapshotId , t . List [ SnapshotId ] ] = {},
385382 ) -> t .Tuple [t .List [NodeExecutionFailedError [SchedulingUnit ]], t .List [SchedulingUnit ]]:
386383 """Runs precomputed batches of missing intervals.
387384
@@ -484,9 +481,7 @@ def evaluate_node(node: SchedulingUnit) -> None:
484481 evaluation_duration_ms ,
485482 num_audits - num_audits_failed ,
486483 num_audits_failed ,
487- snapshot_evaluation_triggers = snapshot_evaluation_triggers .get (
488- snapshot .snapshot_id
489- ),
484+ auto_restatement_triggers = auto_restatement_triggers .get (snapshot .snapshot_id ),
490485 )
491486
492487 try :
@@ -597,7 +592,6 @@ def _run_or_audit(
597592 ignore_cron : bool = False ,
598593 end_bounded : bool = False ,
599594 selected_snapshots : t .Optional [t .Set [str ]] = None ,
600- selected_snapshots_auto_upstream : t .Optional [t .Set [str ]] = None ,
601595 circuit_breaker : t .Optional [t .Callable [[], bool ]] = None ,
602596 deployability_index : t .Optional [DeployabilityIndex ] = None ,
603597 auto_restatement_enabled : bool = False ,
@@ -621,7 +615,6 @@ def _run_or_audit(
621615 end_bounded: If set to true, the evaluated intervals will be bounded by the target end date, disregarding lookback,
622616 allow_partials, and other attributes that could cause the intervals to exceed the target end date.
623617 selected_snapshots: A set of snapshot names to run. If not provided, all snapshots will be run.
624- selected_snapshots_auto_upstream: The set of selected_snapshots that were automatically added because they're upstream of a selected snapshot.
625618 circuit_breaker: An optional handler which checks if the run should be aborted.
626619 deployability_index: Determines snapshots that are deployable in the context of this render.
627620 auto_restatement_enabled: Whether to enable auto restatements.
@@ -680,38 +673,9 @@ def _run_or_audit(
680673 return CompletionStatus .NOTHING_TO_DO
681674
682675 merged_intervals_snapshots = {snapshot .snapshot_id for snapshot in merged_intervals }
683- select_snapshot_triggers : t .Dict [SnapshotId , t .List [SnapshotId ]] = {}
684- if selected_snapshots and selected_snapshots_auto_upstream :
685- # actually selected snapshots are their own triggers
686- selected_snapshots_no_auto_upstream = (
687- selected_snapshots - selected_snapshots_auto_upstream
688- )
689- select_snapshot_triggers = {
690- s_id : [s_id ]
691- for s_id in [
692- snapshot_id
693- for snapshot_id in merged_intervals_snapshots
694- if snapshot_id .name in selected_snapshots_no_auto_upstream
695- ]
696- }
697676
698- # trace upstream by walking downstream on reversed dag
699- reversed_dag = snapshots_to_dag (self .snapshots .values ()).reversed
700- for s_id in reversed_dag :
701- if s_id in merged_intervals_snapshots :
702- triggers = select_snapshot_triggers .get (s_id , [])
703- for parent_s_id in reversed_dag .graph .get (s_id , set ()):
704- triggers .extend (select_snapshot_triggers .get (parent_s_id , []))
705- select_snapshot_triggers [s_id ] = list (dict .fromkeys (triggers ))
706-
707- all_snapshot_triggers : t .Dict [SnapshotId , SnapshotEvaluationTriggers ] = {
708- s_id : SnapshotEvaluationTriggers (
709- ignore_cron_flag = ignore_cron ,
710- cron_ready = s_id not in auto_restated_snapshots ,
711- auto_restatement_triggers = auto_restatement_triggers .get (s_id , []),
712- select_snapshot_triggers = select_snapshot_triggers .get (s_id , []),
713- )
714- for s_id in merged_intervals_snapshots
677+ auto_restatement_triggers_dict : t .Dict [SnapshotId , t .List [SnapshotId ]] = {
678+ s_id : auto_restatement_triggers .get (s_id , []) for s_id in merged_intervals_snapshots
715679 }
716680
717681 errors , _ = self .run_merged_intervals (
@@ -725,7 +689,7 @@ def _run_or_audit(
725689 run_environment_statements = run_environment_statements ,
726690 audit_only = audit_only ,
727691 restatements = remove_intervals ,
728- snapshot_evaluation_triggers = all_snapshot_triggers ,
692+ auto_restatement_triggers = auto_restatement_triggers_dict ,
729693 )
730694
731695 return CompletionStatus .FAILURE if errors else CompletionStatus .SUCCESS
0 commit comments