@@ -3053,3 +3053,55 @@ def test_plan_environment_statements_diff(make_snapshot):
30533053 )
30543054 assert stripped == expected_output
30553055 console_output .close ()
3056+
3057+
3058+ def test_set_choice_for_forward_only_model (make_snapshot ):
3059+ snapshot = make_snapshot (
3060+ SqlModel (
3061+ name = "a" ,
3062+ query = parse_one ("select 1, ds" ),
3063+ dialect = "duckdb" ,
3064+ kind = IncrementalByTimeRangeKind (time_column = "ds" , forward_only = True ),
3065+ )
3066+ )
3067+ snapshot .categorize_as (SnapshotChangeCategory .BREAKING )
3068+ updated_snapshot = make_snapshot (
3069+ SqlModel (
3070+ name = "a" ,
3071+ query = parse_one ("select 3, ds" ),
3072+ kind = IncrementalByTimeRangeKind (time_column = "ds" , forward_only = True ),
3073+ dialect = "duckdb" ,
3074+ )
3075+ )
3076+ updated_snapshot .previous_versions = snapshot .all_versions
3077+
3078+ context_diff = ContextDiff (
3079+ environment = "test_environment" ,
3080+ is_new_environment = True ,
3081+ is_unfinalized_environment = False ,
3082+ normalize_environment_name = True ,
3083+ create_from = "prod" ,
3084+ create_from_env_exists = True ,
3085+ added = set (),
3086+ removed_snapshots = {},
3087+ modified_snapshots = {updated_snapshot .name : (updated_snapshot , snapshot )},
3088+ snapshots = {updated_snapshot .snapshot_id : updated_snapshot },
3089+ new_snapshots = {updated_snapshot .snapshot_id : updated_snapshot },
3090+ previous_plan_id = None ,
3091+ previously_promoted_snapshot_ids = set (),
3092+ previous_finalized_snapshots = None ,
3093+ previous_gateway_managed_virtual_layer = False ,
3094+ gateway_managed_virtual_layer = False ,
3095+ )
3096+
3097+ schema_differ = DuckDBEngineAdapter .SCHEMA_DIFFER
3098+ plan_builder = PlanBuilder (context_diff , schema_differ , is_dev = True )
3099+
3100+ with pytest .raises (PlanError , match = 'Forward-only model "a" cannot be categorized manually.' ):
3101+ plan_builder .set_choice (updated_snapshot , SnapshotChangeCategory .BREAKING )
3102+
3103+ plan = plan_builder .build ()
3104+ assert (
3105+ plan .snapshots [updated_snapshot .snapshot_id ].change_category
3106+ == SnapshotChangeCategory .FORWARD_ONLY
3107+ )
0 commit comments