Skip to content

Commit 202b73c

Browse files
committed
Fix: Refresh snapshot intervals after determining the max interval end per model (#3664)
1 parent d4c10e1 commit 202b73c

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

sqlmesh/core/context.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,9 @@ def plan_builder(
13281328
),
13291329
)
13301330

1331+
# Refresh snapshot intervals to ensure that they are up to date with values reflected in the max_interval_end_per_model.
1332+
self.state_sync.refresh_snapshot_intervals(context_diff.snapshots.values())
1333+
13311334
return self.PLAN_BUILDER_TYPE(
13321335
context_diff=context_diff,
13331336
start=start,

tests/core/test_plan.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -780,15 +780,18 @@ def test_restate_models(sushi_context_pre_scheduling: Context):
780780

781781

782782
@pytest.mark.slow
783-
@time_machine.travel(now(), tick=False)
784-
def test_restate_models_with_existing_missing_intervals(sushi_context: Context):
783+
@time_machine.travel(now(minute_floor=False), tick=False)
784+
def test_restate_models_with_existing_missing_intervals(init_and_plan_context: t.Callable):
785+
sushi_context, plan = init_and_plan_context("examples/sushi")
786+
sushi_context.apply(plan)
787+
785788
yesterday_ts = to_timestamp(yesterday_ds())
786789

787790
assert not sushi_context.plan(no_prompts=True).requires_backfill
788791
waiter_revenue_by_day = sushi_context.snapshots['"memory"."sushi"."waiter_revenue_by_day"']
789-
waiter_revenue_by_day.intervals = [
790-
(waiter_revenue_by_day.intervals[0][0], yesterday_ts),
791-
]
792+
sushi_context.state_sync.remove_intervals(
793+
[(waiter_revenue_by_day, (yesterday_ts, waiter_revenue_by_day.intervals[0][1]))]
794+
)
792795
assert sushi_context.plan(no_prompts=True).requires_backfill
793796

794797
plan = sushi_context.plan(restate_models=["sushi.waiter_revenue_by_day"], no_prompts=True)

0 commit comments

Comments
 (0)