Skip to content

Commit da57f8e

Browse files
committed
Fix: Make sure that changes to seed models are reflected in the dev-only VDE mode
1 parent 75f825e commit da57f8e

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

sqlmesh/core/plan/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
def should_force_rebuild(old: Snapshot, new: Snapshot) -> bool:
77
if new.is_view and new.is_indirect_non_breaking and not new.is_forward_only:
8-
# View models always need to be rebuilt to reflect updated upstream dependencies.
8+
# View models always need to be rebuilt to reflect updated upstream dependencies
9+
return True
10+
if new.is_seed:
11+
# Seed models always need to be rebuilt to reflect changes in the seed file
912
return True
1013
return is_breaking_kind_change(old, new)
1114

tests/core/test_integration.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2918,6 +2918,37 @@ def test_virtual_environment_mode_dev_only_model_kind_change_manual_categorizati
29182918
]
29192919

29202920

2921+
@time_machine.travel("2023-01-08 15:00:00 UTC")
2922+
def test_virtual_environment_mode_dev_only_seed_model_change(
2923+
init_and_plan_context: t.Callable,
2924+
):
2925+
context, plan = init_and_plan_context(
2926+
"examples/sushi", config="test_config_virtual_environment_mode_dev_only"
2927+
)
2928+
context.apply(plan)
2929+
2930+
seed_model = context.get_model("sushi.waiter_names")
2931+
with open(seed_model.seed_path, "a") as fd:
2932+
fd.write("\n123,New Test Name")
2933+
2934+
context.load()
2935+
seed_model_snapshot = context.get_snapshot("sushi.waiter_names")
2936+
plan = context.plan_builder("prod").build()
2937+
assert plan.directly_modified == {seed_model_snapshot.snapshot_id}
2938+
assert len(plan.missing_intervals) == 1
2939+
assert plan.missing_intervals[0].snapshot_id == seed_model_snapshot.snapshot_id
2940+
2941+
context.apply(plan)
2942+
2943+
actual_seed_df = context.fetchdf("SELECT * FROM sushi.waiter_names WHERE id = 123")
2944+
assert actual_seed_df.to_dict("records") == [
2945+
{
2946+
"id": 123,
2947+
"name": "New Test Name",
2948+
}
2949+
]
2950+
2951+
29212952
@time_machine.travel("2023-01-08 15:00:00 UTC")
29222953
def test_restatement_plan_ignores_changes(init_and_plan_context: t.Callable):
29232954
context, plan = init_and_plan_context("examples/sushi")

0 commit comments

Comments
 (0)