Skip to content

Fix: Always recreate virtual views for dev environments#4413

Merged
izeigerman merged 1 commit intomainfrom
fix-always-recreate-views-in-dev-envs
May 14, 2025
Merged

Fix: Always recreate virtual views for dev environments#4413
izeigerman merged 1 commit intomainfrom
fix-always-recreate-views-in-dev-envs

Conversation

@izeigerman
Copy link
Contributor

Depending on how the plan was setup to run for the target development environment, SQLMesh can choose whether to write into the dev table for the changed snapshot.

For example, if the user runs plan while providing a start date which doesn't align with the model start of a FULL model, SQLMesh may choose to write into the dev table since this output cannot be reused in prod.

If, however, the user follows up with another plan targeting the same environment but without an explicit start date, SQLMesh will use the model's start date and choose the non-dev table to insert into. The problem is that, in this case, the backfill will work correctly, but the view in the virtual layer won’t be updated because the snapshot in the target environment technically hasn’t changed. So the view will still be pointing at the dev table and not the non-dev one.

This fix ensures that views are always recreated in the target dev environment for the models that are being backfilled as part of a given plan.

@izeigerman izeigerman requested a review from a team May 14, 2025 20:16
@izeigerman izeigerman changed the title Fix: Always recreate virtual views in dev environments Fix: Always recreate virtual views for dev environments May 14, 2025
@izeigerman izeigerman merged commit 0150154 into main May 14, 2025
20 checks passed
@izeigerman izeigerman deleted the fix-always-recreate-views-in-dev-envs branch May 14, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants