2828 snapshots_to_dag ,
2929 Intervals ,
3030)
31+ from sqlmesh .core .snapshot .definition import check_ready_intervals
3132from sqlmesh .core .snapshot .definition import (
3233 Interval ,
33- SnapshotEvaluationTriggers ,
3434 SnapshotIntervals ,
35- check_ready_intervals ,
3635 expand_range ,
3736 parent_snapshots_by_name ,
3837)
@@ -168,9 +167,6 @@ def merged_missing_intervals(
168167 end_bounded: If set to true, the returned intervals will be bounded by the target end date, disregarding lookback,
169168 allow_partials, and other attributes that could cause the intervals to exceed the target end date.
170169 selected_snapshots: A set of snapshot names to run. If not provided, all snapshots will be run.
171-
172- Returns:
173- A dict containing all snapshots needing to be run with their associated interval params.
174170 """
175171 snapshots_to_intervals = merged_missing_intervals (
176172 snapshots = self .snapshot_per_version .values (),
@@ -267,7 +263,6 @@ def run(
267263 ignore_cron : bool = False ,
268264 end_bounded : bool = False ,
269265 selected_snapshots : t .Optional [t .Set [str ]] = None ,
270- selected_snapshots_auto_upstream : t .Optional [t .Set [str ]] = None ,
271266 circuit_breaker : t .Optional [t .Callable [[], bool ]] = None ,
272267 deployability_index : t .Optional [DeployabilityIndex ] = None ,
273268 auto_restatement_enabled : bool = False ,
@@ -284,7 +279,6 @@ def run(
284279 ignore_cron = ignore_cron ,
285280 end_bounded = end_bounded ,
286281 selected_snapshots = selected_snapshots ,
287- selected_snapshots_auto_upstream = selected_snapshots_auto_upstream ,
288282 circuit_breaker = circuit_breaker ,
289283 deployability_index = deployability_index ,
290284 auto_restatement_enabled = auto_restatement_enabled ,
@@ -422,6 +416,7 @@ def run_merged_intervals(
422416 selected_snapshot_ids : t .Optional [t .Set [SnapshotId ]] = None ,
423417 run_environment_statements : bool = False ,
424418 audit_only : bool = False ,
419+ restatements : t .Optional [t .Dict [SnapshotId , Interval ]] = None ,
425420 auto_restatement_triggers : t .Dict [SnapshotId , t .List [SnapshotId ]] = {},
426421 ) -> t .Tuple [t .List [NodeExecutionFailedError [SchedulingUnit ]], t .List [SchedulingUnit ]]:
427422 """Runs precomputed batches of missing intervals.
@@ -539,9 +534,7 @@ def run_node(node: SchedulingUnit) -> None:
539534 evaluation_duration_ms ,
540535 num_audits - num_audits_failed ,
541536 num_audits_failed ,
542- snapshot_evaluation_triggers = snapshot_evaluation_triggers .get (
543- snapshot .snapshot_id
544- ),
537+ auto_restatement_triggers = auto_restatement_triggers .get (snapshot .snapshot_id ),
545538 )
546539 elif isinstance (node , CreateNode ):
547540 self .snapshot_evaluator .create_snapshot (
@@ -694,7 +687,6 @@ def _run_or_audit(
694687 ignore_cron : bool = False ,
695688 end_bounded : bool = False ,
696689 selected_snapshots : t .Optional [t .Set [str ]] = None ,
697- selected_snapshots_auto_upstream : t .Optional [t .Set [str ]] = None ,
698690 circuit_breaker : t .Optional [t .Callable [[], bool ]] = None ,
699691 deployability_index : t .Optional [DeployabilityIndex ] = None ,
700692 auto_restatement_enabled : bool = False ,
@@ -718,7 +710,6 @@ def _run_or_audit(
718710 end_bounded: If set to true, the evaluated intervals will be bounded by the target end date, disregarding lookback,
719711 allow_partials, and other attributes that could cause the intervals to exceed the target end date.
720712 selected_snapshots: A set of snapshot names to run. If not provided, all snapshots will be run.
721- selected_snapshots_auto_upstream: The set of selected_snapshots that were automatically added because they're upstream of a selected snapshot.
722713 circuit_breaker: An optional handler which checks if the run should be aborted.
723714 deployability_index: Determines snapshots that are deployable in the context of this render.
724715 auto_restatement_enabled: Whether to enable auto restatements.
@@ -777,38 +768,9 @@ def _run_or_audit(
777768 return CompletionStatus .NOTHING_TO_DO
778769
779770 merged_intervals_snapshots = {snapshot .snapshot_id for snapshot in merged_intervals }
780- select_snapshot_triggers : t .Dict [SnapshotId , t .List [SnapshotId ]] = {}
781- if selected_snapshots and selected_snapshots_auto_upstream :
782- # actually selected snapshots are their own triggers
783- selected_snapshots_no_auto_upstream = (
784- selected_snapshots - selected_snapshots_auto_upstream
785- )
786- select_snapshot_triggers = {
787- s_id : [s_id ]
788- for s_id in [
789- snapshot_id
790- for snapshot_id in merged_intervals_snapshots
791- if snapshot_id .name in selected_snapshots_no_auto_upstream
792- ]
793- }
794771
795- # trace upstream by walking downstream on reversed dag
796- reversed_dag = snapshots_to_dag (self .snapshots .values ()).reversed
797- for s_id in reversed_dag :
798- if s_id in merged_intervals_snapshots :
799- triggers = select_snapshot_triggers .get (s_id , [])
800- for parent_s_id in reversed_dag .graph .get (s_id , set ()):
801- triggers .extend (select_snapshot_triggers .get (parent_s_id , []))
802- select_snapshot_triggers [s_id ] = list (dict .fromkeys (triggers ))
803-
804- all_snapshot_triggers : t .Dict [SnapshotId , SnapshotEvaluationTriggers ] = {
805- s_id : SnapshotEvaluationTriggers (
806- ignore_cron_flag = ignore_cron ,
807- cron_ready = s_id not in auto_restated_snapshots ,
808- auto_restatement_triggers = auto_restatement_triggers .get (s_id , []),
809- select_snapshot_triggers = select_snapshot_triggers .get (s_id , []),
810- )
811- for s_id in merged_intervals_snapshots
772+ auto_restatement_triggers_dict : t .Dict [SnapshotId , t .List [SnapshotId ]] = {
773+ s_id : auto_restatement_triggers .get (s_id , []) for s_id in merged_intervals_snapshots
812774 }
813775
814776 errors , _ = self .run_merged_intervals (
0 commit comments