fix: prevent default catalog leak into catalog-unsupported gateways#5750
Open
brucearctor wants to merge 1 commit intoSQLMesh:mainfrom
Open
fix: prevent default catalog leak into catalog-unsupported gateways#5750brucearctor wants to merge 1 commit intoSQLMesh:mainfrom
brucearctor wants to merge 1 commit intoSQLMesh:mainfrom
Conversation
…QLMesh#5748) When a multi-gateway project uses a default gateway with a catalog (e.g. Trino), that catalog was silently prepended to model names targeting secondary gateways that don't support catalogs (e.g. ClickHouse), causing UnsupportedCatalogOperationError at evaluation. Root cause: catalog-unsupported adapters return None for default_catalog and are never added to default_catalog_per_gateway. The model loader cannot distinguish 'no catalog' from 'not checked', so the global default_catalog leaks through. Fix: explicitly register catalog-unsupported gateways with empty string in the per-gateway dict. The model loader's 'is not None' check picks this up and overrides default_catalog to '', preventing the leak. Signed-off-by: Bruce Arctor <brucearctor@users.noreply.github.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
Fixes #5748.
When a multi-gateway SQLMesh project uses a default gateway with a catalog (e.g., Trino with
catalog: example_catalog), that catalog is silently prepended to model names targeting secondary gateways that do not support catalogs (e.g., ClickHouse), causingUnsupportedCatalogOperationErrorat evaluation time.Root cause: The per-gateway catalog dict (
default_catalog_per_gateway) is built inBuiltInSchedulerConfig.get_default_catalog_per_gateway(). Catalog-unsupported adapters returnNonefordefault_catalogand are never added to the dict. The model loader increate_models_from_blueprints()then cannot distinguish "this gateway has no catalog" from "this gateway was not checked", so the globaldefault_catalogleaks through.Fix: Explicitly register catalog-unsupported gateways with empty string (
"") in the per-gateway dict. The model loader's existingis not Nonecheck picks up the empty string and overridesdefault_catalogto"", which does not get prepended to the model name.Changes
sqlmesh/core/config/scheduler.pyelifbranch to register catalog-unsupported gateways with""tests/core/test_model.pytest_default_catalog_not_leaked_to_unsupported_gatewayTest Plan
test_default_catalog_not_leaked_to_unsupported_gatewayregression test that verifies:""indefault_catalog_per_gateway→example_catalogdoes not leak into the model FQNexample_catalogdoes leak (confirming the bug behavior)test_gateway_macro,test_gateway_macro_jinja,test_gateway_python_model,test_gateway_specific_render,test_model_cache_gatewayruffandruff-formatpassmypypasses on changed file (pre-existing unrelated error ingateway.py)Checklist
make styleand fixed any issuesmake fast-test)git commit -s) per the DCO