Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Support top level properties in model_defaults #3696

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

themisvaltinos
Copy link
Contributor

@themisvaltinos themisvaltinos commented Jan 23, 2025

This update extends the support for top-level properties to be enabled project wide, fixes: #3599

  • when both project-wide and model-specific properties are defined, they are combined.
  • if a property is set at the model level, it takes precedence over the project-wide setting.
  • if a user wants to unset a project-wide property on a specific model, they can do so by explicitly setting it to None.

Don't know if it makes sense to include more, as the others seem quite model-specific, but I’m happy to add them if anyone feels they’re necessary.

@@ -40,6 +40,7 @@ Configuration options for SQLMesh model properties. Supported by all model kinds
| `gateway` | Specifies the gateway to use for the execution of this model. When not specified, the default gateway is used. | str | N |
| `optimize_query` | Whether the model's query should be optimized. This attribute is `true` by default. Setting it to `false` causes SQLMesh to disable query canonicalization & simplification. This should be turned off only if the optimized query leads to errors such as surpassing text limit. | bool | N |
| `validate_query` | `validate_query` | Whether the model's query will be strictly validated at compile time. This attribute is `false` by default. Setting it to `true` causes SQLMesh to raise an error instead of emitting warnings. This will display invalid columns in your SQL statements along with models containing `SELECT *` that cannot be automatically expanded to list out all columns. | bool | N |

### Model defaults
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to add a note somewhere in the docs about how to un-set a default at the model level.

It looks like this is supported by defining the property as None at the model level

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes good point, added an explanation and an example to make it clear how to unset a property

Copy link
Contributor

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one comment.

session_properties[k] = exp.Literal.string(k).eq(v)
if k not in properties:
properties[k] = exp.Literal.string(k).eq(v)
elif properties[k].expression.sql().lower() in {"none", "null"}:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is matching null here safe? Can that be an actual property value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to match for python models properties where None will be null here

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.

Support all top-level properties in model_defaults
3 participants