Skip to content

fix(model): apply model_defaults kind to SQL models - #6112

Open
manan28025 wants to merge 1 commit into
SQLMesh:mainfrom
manan28025:model-defaults-kind
Open

manan28025 wants to merge 1 commit into
SQLMesh:mainfrom
manan28025:model-defaults-kind

Conversation

@manan28025

Copy link
Copy Markdown
Contributor

Description

Fixes #5709.

model_defaults.kind is listed as a supported default, but SQL models ignore it. When a model's MODEL block has no kind, load_sql_based_model() falls back to the ModelMeta default (VIEW) and passes it to create_sql_model() explicitly. That overrides the kind from the project defaults when the model is built. Python models don't go through that path, so with the same project they already get the default kind while SQL models end up as views.

The fix uses the kind from model_defaults when the model doesn't set one, and only falls back to VIEW when there's no default.

Projects that already set kind in model_defaults will see those SQL models change from VIEW to the configured kind after upgrading.

Test Plan

  • Added test_model_defaults_kind: a model without a kind gets the default kind, and an explicit kind VIEW still takes precedence. It fails on main and passes with the fix.
  • Checked the setup from the issue with DuckDB: models now load as FULL (they were VIEW before).
  • Ran the fast and slow tests in tests/core. The only failures are MSSQL/Fabric connection tests that need pyodbc / mssql-python, which I don't have installed. They fail the same way on main.

Checklist

  • I have run make style and fixed any issues
  • I have added tests for my changes (if applicable)
  • All existing tests pass (make fast-test) (ran the tests/core fast and slow suites, see above)
  • My commits are signed off (git commit -s) per the DCO

A SQL model without a kind in its MODEL block was given the ModelMeta
default (VIEW) before the project defaults were merged in, so
model_defaults.kind was ignored. Python models already used it. Fall back
to the default kind from model_defaults first.

Signed-off-by: neatninja <manan81140@gmail.com>
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.

databricks - model default parameter not recognised

2 participants