Skip to content

Feat!: Dev-only VDE mode#5087

Merged
izeigerman merged 27 commits intomainfrom
feat-non-virtual-prod
Aug 12, 2025
Merged

Feat!: Dev-only VDE mode#5087
izeigerman merged 27 commits intomainfrom
feat-non-virtual-prod

Conversation

@izeigerman
Copy link
Collaborator

This PR adds support for the dev_only Virtual Data Environment (VDE) mode.

In this mode VDE is applied only in development environments, while in production, model tables and views are updated directly, bypassing the virtual layer. This also means that physical tables in production will be created using the original, unversioned model names. Users will continue to benefit from VDE and data reuse across development environments.

The new mode can be enabled in the project configuration:

virtual_environment_mode: 'dev_only'

Switching the mode for an existing project will result in a complete rebuild of all models in the project.

@izeigerman izeigerman requested a review from a team July 31, 2025 23:47
@izeigerman izeigerman force-pushed the feat-non-virtual-prod branch from 2a32f29 to afcef50 Compare July 31, 2025 23:52
@izeigerman izeigerman marked this pull request as draft August 1, 2025 22:51
@izeigerman izeigerman force-pushed the feat-non-virtual-prod branch 3 times, most recently from b268cea to c6844d6 Compare August 11, 2025 15:51
@izeigerman izeigerman force-pushed the feat-non-virtual-prod branch from 5e06d2e to 2ac5969 Compare August 11, 2025 18:53
@izeigerman izeigerman marked this pull request as ready for review August 11, 2025 19:06
DEV_ONLY: Bypass virtual environments in production, using original unversioned model names.
"""

FULL = "full"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Is the term "FULL" being used because of "FULL" in auto-categorization? "ALL" feels better to me but I'm wondering if there is some intention behind using "FULL" that I am missing.

Comment on lines +265 to +268
if self.plan.use_finalized_state and not self.virtual_environment_mode.is_full:
raise ConfigError(
"Using the finalized state is only supported when `virtual_environment_mode` is set to `full`."
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this because a "partial" state doesn't make sense if you aren't using VDE in prod? If so, what would be the negative in allowing this? Just doesn't have much meaning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, since dev-only VDE always assumes a forward-only plan, this check is no longer relevant. Will remove it, thanks

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this more and concluded that indeed this configuration is meaningless when used with dev-only VDEs since there are no previous table versions to go back to.

dev_table_suffix: str
model_gateway: t.Optional[str] = None
forward_only: bool = False
table_naming_convention: TableNamingConvention = TableNamingConvention.default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, I struggled to get this to work. mypy wouldnt let me have it both here and on SnapshotInfoMixin

Copy link
Contributor

@sungchun12 sungchun12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick docs suggestions.

@izeigerman izeigerman force-pushed the feat-non-virtual-prod branch from 75b9b48 to 282cfe3 Compare August 12, 2025 17:51
@izeigerman izeigerman merged commit 4379581 into main Aug 12, 2025
27 of 28 checks passed
@izeigerman izeigerman deleted the feat-non-virtual-prod branch August 12, 2025 18:14
@codykonior-hsi
Copy link

codykonior-hsi commented Aug 22, 2025

Switching the mode for an existing project will result in a complete rebuild of all models in the project.

For anyone finding this at a later date, the rebuild required is a manual one, not automatic, at least in 0.210.0 and some projects (in my case multi-repo projects where models reference one-way across projects).

When changing virtual_environment_mode from full to dev_only, sqlmesh drops all of the old views first, and does not create the replacement models in the correct order. When it goes to create models further down the chain, they will fail because the model tables it depends on do not exist yet.

In that case you can destroy and plan from scratch to make it work. So, when changing a project's virtual_environment_mode from full to dev_only you should be prepared to destroy and plan.

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.

5 participants