@@ -2964,7 +2964,7 @@ def test_new_forward_only_model_concurrent_versions(init_and_plan_context: t.Cal
29642964 )
29652965 new_model_alt = load_sql_based_model (new_model_alt_expr )
29662966
2967- # Add the second version of the model and apply it to dev_b.
2967+ # Add the second version of the model but don't apply it yet
29682968 context .upsert_model (new_model_alt )
29692969 snapshot_b = context .get_snapshot (new_model_alt .name )
29702970 plan_b = context .plan_builder ("dev_b" ).build ()
@@ -2977,8 +2977,6 @@ def test_new_forward_only_model_concurrent_versions(init_and_plan_context: t.Cal
29772977 assert snapshot_b .fingerprint != snapshot_a .fingerprint
29782978 assert snapshot_b .version == snapshot_a .version
29792979
2980- context .apply (plan_b )
2981-
29822980 # Apply the 1st version to prod
29832981 context .upsert_model (new_model )
29842982 plan_prod_a = context .plan_builder ("prod" ).build ()
@@ -2992,10 +2990,20 @@ def test_new_forward_only_model_concurrent_versions(init_and_plan_context: t.Cal
29922990 df = context .fetchdf ("SELECT * FROM memory.sushi.new_model" )
29932991 assert df .to_dict () == {"ds" : {0 : "2023-01-07" }, "a" : {0 : 1 }}
29942992
2993+ # Modify the 1st version in prod to trigger a forward-only change
2994+ new_model = add_projection_to_model (t .cast (SqlModel , new_model ))
2995+ context .upsert_model (new_model )
2996+ context .plan ("prod" , auto_apply = True , no_prompts = True , skip_tests = True )
2997+
2998+ # Apply the 2nd version to dev_b.
2999+ # At this point the snapshot of the 2nd version has already been categorized but not
3000+ # persisted in the state. This means that when the snapshot of the 1st version was
3001+ # being unpaused during promotion to prod, the state of the 2nd version snapshot was not updated
3002+ context .apply (plan_b )
3003+
29953004 # Apply the 2nd version to prod
29963005 context .upsert_model (new_model_alt )
29973006 plan_prod_b = context .plan_builder ("prod" ).build ()
2998- assert snapshot_b .snapshot_id in plan_prod_b .snapshots
29993007 assert (
30003008 plan_prod_b .snapshots [snapshot_b .snapshot_id ].change_category
30013009 == SnapshotChangeCategory .BREAKING
0 commit comments