Feat: Configure virtual layer catalogs per gateway - #5963
Draft
josephfinlayson wants to merge 3 commits into
Draft
Feat: Configure virtual layer catalogs per gateway#5963josephfinlayson wants to merge 3 commits into
josephfinlayson wants to merge 3 commits into
Conversation
Signed-off-by: Joseph Finlayson <joseph.finlayson@gmail.com>
Signed-off-by: Joseph Finlayson <joseph.finlayson@gmail.com>
Signed-off-by: Joseph Finlayson <joseph.finlayson@gmail.com>
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.
Description
SQLMesh can already route a model's execution and gateway-managed virtual layer through its effective gateway. However, the gateway connection's default catalog also qualifies the model, so it determines both the physical snapshot catalog and, normally, the published-view catalog.
environment_catalog_mappingcan move published views, but it applies one environment-wide catalog override. A shared environment therefore cannot preserve separate physical catalogs while publishing each gateway's models into a different stable catalog.This adds an optional
virtual_layer_catalogtoGatewayConfig:With this configuration, versioned snapshot tables remain in
project_a_physical, while stable environment views are published inproject_a_published. The route is configured once per gateway rather than repeated on individual models.Resolution and precedence
model_defaults.gateway, then the selected gateway.virtual_layer_catalogdetermines the base catalog of the model's published environment view.environment_catalog_mappingretains precedence for backward compatibility.virtual_layer_catalogproperties are rejected; this is intentionally a gateway-level policy.State and lifecycle behavior
The resolved route is stored with model and snapshot metadata, including
SnapshotTableInfo. This lets a partial multi-project plan preserve the published locations of remote snapshots loaded from shared state even when their project configuration is not loaded.Changing only
virtual_layer_catalogis a metadata-only change. Applying that plan publishes the existing snapshot through the new catalog and demotes the previous view without rebuilding the physical table. Janitor cleanup also uses the persisted route.Composed project configurations must agree when they define the same gateway name. Conflicting
virtual_layer_catalogvalues raise a configuration error instead of making route resolution depend on project load order.Compatibility
virtual_layer_catalogpreserves existing model metadata hashes and publishing behavior.environment_catalog_mappingbehavior and precedence are unchanged.Prior art and design choice
This builds on SQLMesh's model-level multi-engine routing (#3394), gateway-specific model defaults (#3888), gateway-managed virtual layers (#4101), and environment catalog naming (#4742).
It deliberately avoids a per-model catalog override. #3645 raised the same API-proliferation concern for physical schema routing; a gateway-level policy keeps routing centralized while explicit model gateways continue to provide the existing model-level escape hatch. #4684 tracks the broader, separate problem of generic physical catalog/schema mapping.
dbt provides related but not identical precedents: hierarchical project/directory relation configuration, logical catalog mappings in
catalogs.yml, and stable latest-version pointers. This change keeps SQLMesh's existing snapshot and environment semantics while applying the same separation of physical storage from a stable published name.Test plan
make stylemake fast-test(2,787 passed across the fast, isolated, registry-isolation, and dialect-isolation phases; 4 skipped)Checklist
make styleand fixed any issues.