fix(model): apply model_defaults kind to SQL models - #6112
Open
manan28025 wants to merge 1 commit into
Open
manan28025 wants to merge 1 commit into
manan28025 wants to merge 1 commit into
Conversation
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>
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 #5709.
model_defaults.kindis listed as a supported default, but SQL models ignore it. When a model's MODEL block has nokind,load_sql_based_model()falls back to theModelMetadefault (VIEW) and passes it tocreate_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_defaultswhen the model doesn't set one, and only falls back toVIEWwhen there's no default.Projects that already set
kindinmodel_defaultswill see those SQL models change fromVIEWto the configured kind after upgrading.Test Plan
test_model_defaults_kind: a model without a kind gets the default kind, and an explicitkind VIEWstill takes precedence. It fails on main and passes with the fix.FULL(they wereVIEWbefore).Checklist
make styleand fixed any issuesmake fast-test) (ran the tests/core fast and slow suites, see above)git commit -s) per the DCO