Fix: Always recreate virtual views for dev environments#4413
Merged
izeigerman merged 1 commit intomainfrom May 14, 2025
Merged
Conversation
tobymao
approved these changes
May 14, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.