@@ -701,6 +701,72 @@ def test_cron_not_aligned_with_day_boundary(
701701 ]
702702
703703
704+ @time_machine .travel ("2023-01-08 00:00:00 UTC" )
705+ def test_cron_not_aligned_with_day_boundary_new_model (init_and_plan_context : t .Callable ):
706+ context , _ = init_and_plan_context ("examples/sushi" )
707+
708+ existing_model = context .get_model ("sushi.waiter_revenue_by_day" )
709+ existing_model = SqlModel .parse_obj (
710+ {
711+ ** existing_model .dict (),
712+ "kind" : existing_model .kind .copy (update = {"forward_only" : True }),
713+ }
714+ )
715+ context .upsert_model (existing_model )
716+
717+ plan = context .plan_builder ("prod" , skip_tests = True ).build ()
718+ context .apply (plan )
719+
720+ # Add a new model and make a change to a forward-only model.
721+ # The cron of the new model is not aligned with the day boundary.
722+ new_model = load_sql_based_model (
723+ d .parse (
724+ """
725+ MODEL (
726+ name memory.sushi.new_model,
727+ kind FULL,
728+ cron '0 8 * * *',
729+ start '2023-01-01',
730+ );
731+
732+ SELECT 1 AS one;
733+ """
734+ )
735+ )
736+ context .upsert_model (new_model )
737+
738+ existing_model = add_projection_to_model (t .cast (SqlModel , existing_model ), literal = True )
739+ context .upsert_model (existing_model )
740+
741+ plan = context .plan_builder ("dev" , skip_tests = True , enable_preview = True ).build ()
742+ assert plan .missing_intervals == [
743+ SnapshotIntervals (
744+ snapshot_id = context .get_snapshot (
745+ "memory.sushi.new_model" , raise_if_missing = True
746+ ).snapshot_id ,
747+ intervals = [(to_timestamp ("2023-01-06" ), to_timestamp ("2023-01-07" ))],
748+ ),
749+ SnapshotIntervals (
750+ snapshot_id = context .get_snapshot (
751+ "sushi.top_waiters" , raise_if_missing = True
752+ ).snapshot_id ,
753+ intervals = [
754+ (to_timestamp ("2023-01-06" ), to_timestamp ("2023-01-07" )),
755+ (to_timestamp ("2023-01-07" ), to_timestamp ("2023-01-08" )),
756+ ],
757+ ),
758+ SnapshotIntervals (
759+ snapshot_id = context .get_snapshot (
760+ "sushi.waiter_revenue_by_day" , raise_if_missing = True
761+ ).snapshot_id ,
762+ intervals = [
763+ (to_timestamp ("2023-01-06" ), to_timestamp ("2023-01-07" )),
764+ (to_timestamp ("2023-01-07" ), to_timestamp ("2023-01-08" )),
765+ ],
766+ ),
767+ ]
768+
769+
704770@time_machine .travel ("2023-01-08 00:00:00 UTC" )
705771def test_forward_only_monthly_model (init_and_plan_context : t .Callable ):
706772 context , _ = init_and_plan_context ("examples/sushi" )
0 commit comments