@@ -379,6 +379,48 @@ def test_hourly_model_with_lookback_no_backfill_in_dev(init_and_plan_context: t.
379379 ]
380380
381381
382+ @freeze_time ("2023-01-08 00:00:00" )
383+ def test_parent_cron_before_child (init_and_plan_context : t .Callable ):
384+ context , plan = init_and_plan_context ("examples/sushi" )
385+
386+ model = context .get_model ("sushi.waiter_revenue_by_day" )
387+ model = SqlModel .parse_obj (
388+ {
389+ ** model .dict (),
390+ "cron" : "50 23 * * *" ,
391+ }
392+ )
393+ context .upsert_model (model )
394+
395+ plan = context .plan ("prod" , no_prompts = True , skip_tests = True )
396+ context .apply (plan )
397+
398+ top_waiters_model = context .get_model ("sushi.top_waiters" )
399+ top_waiters_model = add_projection_to_model (t .cast (SqlModel , top_waiters_model ), literal = True )
400+ context .upsert_model (top_waiters_model )
401+
402+ snapshot = context .get_snapshot (model , raise_if_missing = True )
403+ top_waiters_snapshot = context .get_snapshot ("sushi.top_waiters" , raise_if_missing = True )
404+
405+ with freeze_time ("2023-01-08 23:55:00" ): # Past parent's cron, but before child's
406+ plan = context .plan ("dev" , no_prompts = True , skip_tests = True )
407+ # Make sure the waiter_revenue_by_day model is not backfilled.
408+ assert plan .missing_intervals == [
409+ SnapshotIntervals (
410+ snapshot_id = top_waiters_snapshot .snapshot_id ,
411+ intervals = [
412+ (to_timestamp ("2023-01-01" ), to_timestamp ("2023-01-02" )),
413+ (to_timestamp ("2023-01-02" ), to_timestamp ("2023-01-03" )),
414+ (to_timestamp ("2023-01-03" ), to_timestamp ("2023-01-04" )),
415+ (to_timestamp ("2023-01-04" ), to_timestamp ("2023-01-05" )),
416+ (to_timestamp ("2023-01-05" ), to_timestamp ("2023-01-06" )),
417+ (to_timestamp ("2023-01-06" ), to_timestamp ("2023-01-07" )),
418+ (to_timestamp ("2023-01-07" ), to_timestamp ("2023-01-08" )),
419+ ],
420+ ),
421+ ]
422+
423+
382424@freeze_time ("2023-01-08 15:00:00" )
383425def test_forward_only_parent_created_in_dev_child_created_in_prod (
384426 init_and_plan_context : t .Callable ,
0 commit comments