@@ -2986,6 +2986,63 @@ def _make_forward_only_preview_context_diff(make_snapshot):
29862986 return context_diff , new_snapshot
29872987
29882988
2989+ def test_forward_only_preview_start_does_not_override_implicit_backfill_start (make_snapshot ):
2990+ context_diff , new_snapshot = _make_forward_only_preview_context_diff (make_snapshot )
2991+
2992+ normal_old_snapshot = make_snapshot (
2993+ SqlModel (
2994+ name = "normal" ,
2995+ query = parse_one ("select 1, ds" ),
2996+ dialect = "duckdb" ,
2997+ kind = dict (name = ModelKindName .INCREMENTAL_BY_TIME_RANGE , time_column = "ds" ),
2998+ start = "2025-01-01" ,
2999+ )
3000+ )
3001+ normal_old_snapshot .categorize_as (SnapshotChangeCategory .BREAKING )
3002+ normal_new_snapshot = make_snapshot (
3003+ SqlModel (
3004+ name = "normal" ,
3005+ query = parse_one ("select 2, ds" ),
3006+ dialect = "duckdb" ,
3007+ kind = dict (name = ModelKindName .INCREMENTAL_BY_TIME_RANGE , time_column = "ds" ),
3008+ start = "2025-01-01" ,
3009+ )
3010+ )
3011+ normal_new_snapshot .previous_versions = normal_old_snapshot .all_versions
3012+
3013+ context_diff .modified_snapshots [normal_new_snapshot .name ] = (
3014+ normal_new_snapshot ,
3015+ normal_old_snapshot ,
3016+ )
3017+ context_diff .snapshots [normal_new_snapshot .snapshot_id ] = normal_new_snapshot
3018+ context_diff .new_snapshots [normal_new_snapshot .snapshot_id ] = normal_new_snapshot
3019+
3020+ plan = PlanBuilder (
3021+ context_diff ,
3022+ default_start = "2025-01-01" ,
3023+ end = "2025-01-04" ,
3024+ preview_start = "2025-01-03" ,
3025+ skip_backfill = False ,
3026+ is_dev = True ,
3027+ enable_preview = True ,
3028+ ).build ()
3029+
3030+ assert plan .start == "2025-01-01"
3031+ assert plan .restatements == {
3032+ new_snapshot .snapshot_id : (
3033+ to_timestamp ("2025-01-03" ),
3034+ to_timestamp ("2025-01-05" ),
3035+ )
3036+ }
3037+ missing_intervals = {i .snapshot_id : i .intervals for i in plan .missing_intervals }
3038+ assert missing_intervals [normal_new_snapshot .snapshot_id ] == [
3039+ (to_timestamp ("2025-01-01" ), to_timestamp ("2025-01-02" )),
3040+ (to_timestamp ("2025-01-02" ), to_timestamp ("2025-01-03" )),
3041+ (to_timestamp ("2025-01-03" ), to_timestamp ("2025-01-04" )),
3042+ (to_timestamp ("2025-01-04" ), to_timestamp ("2025-01-05" )),
3043+ ]
3044+
3045+
29893046def test_forward_only_preview_start_does_not_limit_regular_backfill (make_snapshot ):
29903047 context_diff , preview_new_snapshot = _make_forward_only_preview_context_diff (make_snapshot )
29913048
0 commit comments