@@ -4572,6 +4572,33 @@ def test_restatement_of_full_model_with_start(init_and_plan_context: t.Callable)
45724572 assert waiter_by_day_interval == (to_timestamp ("2023-01-07" ), to_timestamp ("2023-01-08" ))
45734573
45744574
4575+ @time_machine .travel ("2023-01-08 15:00:00 UTC" )
4576+ def test_restatement_shouldnt_backfill_beyond_prod_intervals (init_and_plan_context : t .Callable ):
4577+ context , _ = init_and_plan_context ("examples/sushi" )
4578+
4579+ model = context .get_model ("sushi.top_waiters" )
4580+ context .upsert_model (SqlModel .parse_obj ({** model .dict (), "cron" : "@hourly" }))
4581+
4582+ context .plan ("prod" , auto_apply = True , no_prompts = True , skip_tests = True )
4583+ context .run ()
4584+
4585+ with time_machine .travel ("2023-01-09 02:00:00 UTC" ):
4586+ # It's time to backfill the waiter_revenue_by_day model but it hasn't run yet
4587+ restatement_plan = context .plan (
4588+ restate_models = ["sushi.waiter_revenue_by_day" ],
4589+ no_prompts = True ,
4590+ skip_tests = True ,
4591+ )
4592+ intervals_by_id = {i .snapshot_id : i for i in restatement_plan .missing_intervals }
4593+ # Make sure the intervals don't go beyond the prod intervals
4594+ assert intervals_by_id [context .get_snapshot ("sushi.top_waiters" ).snapshot_id ].intervals [- 1 ][
4595+ 1
4596+ ] == to_timestamp ("2023-01-08 15:00:00 UTC" )
4597+ assert intervals_by_id [
4598+ context .get_snapshot ("sushi.waiter_revenue_by_day" ).snapshot_id
4599+ ].intervals [- 1 ][1 ] == to_timestamp ("2023-01-08 00:00:00 UTC" )
4600+
4601+
45754602def initial_add (context : Context , environment : str ):
45764603 assert not context .state_reader .get_environment (environment )
45774604
0 commit comments