Skip to content

Feat: Support gateway in model defaults - #5962

Open
josephfinlayson wants to merge 3 commits into
SQLMesh:mainfrom
josephfinlayson:feat/model-default-gateway
Open

Feat: Support gateway in model defaults#5962
josephfinlayson wants to merge 3 commits into
SQLMesh:mainfrom
josephfinlayson:feat/model-default-gateway

Conversation

@josephfinlayson

@josephfinlayson josephfinlayson commented Aug 20, 2026

Copy link
Copy Markdown

Description

Multi-project contexts can already load models from independently configured projects into one graph and shared state store. However, a model without an explicit gateway currently inherits the one context-selected gateway, so every model in a secondary project must repeat the same gateway property.

This adds model_defaults.gateway as a project-level default for managed SQL, Python, and seed models:

model_defaults:
  dialect: duckdb
  gateway: project_gateway

The default is resolved before model name qualification, so the model receives the selected gateway's default catalog and gateway variables. An explicit gateway in a SQL MODEL block or Python decorator still takes precedence.

Plain Python decorator gateway strings are treated as literal gateway names, including names with characters such as hyphens. Macro-prefixed Python gateway values retain blueprint rendering, as do SQL MODEL gateway expressions.

External models intentionally remain gateway-neutral unless their YAML row specifies a gateway. For external models, gateway selects an alternate source definition rather than an execution default.

No behavior changes when model_defaults.gateway is omitted.

Prior art

This builds on:

Test plan

  • Added SQL model coverage for project defaults, explicit overrides, gateway variables, gateway-specific default catalogs, and hyphenated gateway names.
  • Added Python model and blueprint coverage, including literal hyphenated gateways and macro-prefixed blueprint gateways.
  • Added external-model regression coverage.
  • Added a two-project Context integration test proving each project uses its own default gateway, catalog, and variables while explicit overrides still win.
  • make style
  • make fast-test (2,777 passed across the fast, isolated, registry-isolation, and dialect-isolation phases)
  • Focused model/config/schema-loader plus new slow integration test (412 passed)

Checklist

  • I have run make style and fixed any issues.
  • I have added tests for my changes.
  • All existing tests pass (make fast-test).
  • My commits are signed off per the DCO.

Signed-off-by: Joseph Finlayson <joseph.finlayson@gmail.com>
@josephfinlayson
josephfinlayson marked this pull request as ready for review August 20, 2026 23:29
@cmgoffena13 cmgoffena13 self-assigned this Aug 20, 2026
Signed-off-by: Joseph Finlayson <joseph.finlayson@gmail.com>
@cmgoffena13

Copy link
Copy Markdown
Collaborator

Looks good to me, let me fix the jobs and see if anything comes up. I have a PR to fix the failing dbt test and the other python tests should succeed on retries (found a UTC boundary bug in there). Once all the CI jobs are green I'll merge.

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