@@ -1880,3 +1880,56 @@ def _run_restatement_plan(tmp_path: Path, config: Config, q: queue.Queue):
18801880 assert len (model_a .intervals )
18811881
18821882 set_console (orig_console )
1883+
1884+
1885+ @time_machine .travel ("2023-01-08 15:00:00 UTC" )
1886+ def test_restatement_plan_outside_parent_date_range (init_and_plan_context : t .Callable ):
1887+ context , _ = init_and_plan_context ("examples/sushi" )
1888+
1889+ context .upsert_model ("sushi.items" , start = "2023-01-06" )
1890+ context .upsert_model ("sushi.orders" , start = "2023-01-06" )
1891+ # One of the parents should derive the start from its own parents for the issue
1892+ # to reproduce
1893+ context .upsert_model ("sushi.order_items" , start = None )
1894+ context .upsert_model ("sushi.waiter_revenue_by_day" , start = "2023-01-01" , audits = [])
1895+
1896+ context .plan ("prod" , auto_apply = True , no_prompts = True , skip_tests = True )
1897+
1898+ restated_snapshot = context .get_snapshot ("sushi.waiter_revenue_by_day" )
1899+ downstream_snapshot = context .get_snapshot ("sushi.top_waiters" )
1900+
1901+ plan = context .plan_builder (
1902+ restate_models = ["sushi.waiter_revenue_by_day" ],
1903+ start = "2023-01-01" ,
1904+ end = "2023-01-01" ,
1905+ min_intervals = 0 ,
1906+ ).build ()
1907+ assert plan .snapshots != context .snapshots
1908+
1909+ assert plan .requires_backfill
1910+ assert plan .restatements == {
1911+ restated_snapshot .snapshot_id : (to_timestamp ("2023-01-01" ), to_timestamp ("2023-01-02" )),
1912+ downstream_snapshot .snapshot_id : (to_timestamp ("2023-01-01" ), to_timestamp ("2023-01-09" )),
1913+ }
1914+ assert plan .missing_intervals == [
1915+ SnapshotIntervals (
1916+ snapshot_id = downstream_snapshot .snapshot_id ,
1917+ intervals = [
1918+ (to_timestamp ("2023-01-01" ), to_timestamp ("2023-01-02" )),
1919+ (to_timestamp ("2023-01-02" ), to_timestamp ("2023-01-03" )),
1920+ (to_timestamp ("2023-01-03" ), to_timestamp ("2023-01-04" )),
1921+ (to_timestamp ("2023-01-04" ), to_timestamp ("2023-01-05" )),
1922+ (to_timestamp ("2023-01-05" ), to_timestamp ("2023-01-06" )),
1923+ (to_timestamp ("2023-01-06" ), to_timestamp ("2023-01-07" )),
1924+ (to_timestamp ("2023-01-07" ), to_timestamp ("2023-01-08" )),
1925+ ],
1926+ ),
1927+ SnapshotIntervals (
1928+ snapshot_id = restated_snapshot .snapshot_id ,
1929+ intervals = [
1930+ (to_timestamp ("2023-01-01" ), to_timestamp ("2023-01-02" )),
1931+ ],
1932+ ),
1933+ ]
1934+
1935+ context .apply (plan )
0 commit comments