Skip to content

Commit d7dda8f

Browse files
authored
Fix: Modifying a standalone audit when using the dev-only virtual environment mode (#5383)
1 parent 8dd5e38 commit d7dda8f

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

sqlmesh/core/plan/common.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ def should_force_rebuild(old: Snapshot, new: Snapshot) -> bool:
2323

2424

2525
def is_breaking_kind_change(old: Snapshot, new: Snapshot) -> bool:
26+
if new.is_model != old.is_model:
27+
# If one is a model and the other isn't, then we need to rebuild
28+
return True
29+
if not new.is_model or not old.is_model:
30+
# If neither are models, then we don't need to rebuild
31+
# Note that the remaining checks only apply to model snapshots
32+
return False
2633
if old.virtual_environment_mode != new.virtual_environment_mode:
2734
# If the virtual environment mode has changed, then we need to rebuild
2835
return True

tests/core/test_integration.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3116,7 +3116,32 @@ def test_virtual_environment_mode_dev_only_model_change_downstream_of_seed(
31163116

31173117
# Make sure there's no error when applying the plan
31183118
context.apply(plan)
3119-
context.plan("prod", auto_apply=True, no_prompts=True)
3119+
3120+
3121+
@time_machine.travel("2023-01-08 15:00:00 UTC")
3122+
def test_virtual_environment_mode_dev_only_model_change_standalone_audit(
3123+
init_and_plan_context: t.Callable,
3124+
):
3125+
context, plan = init_and_plan_context(
3126+
"examples/sushi", config="test_config_virtual_environment_mode_dev_only"
3127+
)
3128+
context.apply(plan)
3129+
3130+
# Change a model upstream from a standalone audit
3131+
model = context.get_model("sushi.items")
3132+
model = model.copy(update={"stamp": "force new version"})
3133+
context.upsert_model(model)
3134+
3135+
plan = context.plan_builder("prod", skip_tests=True).build()
3136+
3137+
# Make sure the standalone audit is among modified
3138+
assert (
3139+
context.get_snapshot("assert_item_price_above_zero").snapshot_id
3140+
in plan.indirectly_modified[context.get_snapshot("sushi.items").snapshot_id]
3141+
)
3142+
3143+
# Make sure there's no error when applying the plan
3144+
context.apply(plan)
31203145

31213146

31223147
@time_machine.travel("2023-01-08 15:00:00 UTC")

0 commit comments

Comments
 (0)