Skip to content

Commit ccb8767

Browse files
committed
Chore: Move application of pending restatement intervals into the Snapshot class (#3551)
1 parent 0e51dd8 commit ccb8767

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

sqlmesh/core/snapshot/definition.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,17 @@ def update_next_auto_restatement_ts(self, execution_time: TimeLike) -> t.Optiona
10791079
)
10801080
return self.next_auto_restatement_ts
10811081

1082+
def apply_pending_restatement_intervals(self) -> None:
1083+
"""Applies the pending restatement intervals to the snapshot's intervals."""
1084+
for pending_restatement_interval in self.pending_restatement_intervals:
1085+
logger.info(
1086+
"Applying the auto restated interval (%s, %s) to snapshot %s",
1087+
time_like_to_str(pending_restatement_interval[0]),
1088+
time_like_to_str(pending_restatement_interval[1]),
1089+
self.snapshot_id,
1090+
)
1091+
self.intervals = remove_interval(self.intervals, *pending_restatement_interval)
1092+
10821093
@property
10831094
def physical_schema(self) -> str:
10841095
if self.physical_schema_ is not None:
@@ -1985,15 +1996,7 @@ def apply_auto_restatements(
19851996
[*snapshot.pending_restatement_intervals, removal_interval]
19861997
)
19871998

1988-
for pending_restatement_interval in snapshot.pending_restatement_intervals:
1989-
logger.info(
1990-
"Applying the auto restated interval (%s, %s) to snapshot %s",
1991-
time_like_to_str(pending_restatement_interval[0]),
1992-
time_like_to_str(pending_restatement_interval[1]),
1993-
snapshot.snapshot_id,
1994-
)
1995-
snapshot.intervals = remove_interval(snapshot.intervals, *pending_restatement_interval)
1996-
1999+
snapshot.apply_pending_restatement_intervals()
19972000
snapshot.update_next_auto_restatement_ts(execution_time)
19982001

19992002
return [

0 commit comments

Comments
 (0)