Add model defaults at the subfolder level within the `models/` directory
Let's make it easy to add model defaults to different subfolders within a sqlmesh project. We have it at the project level and individual model level, but nothing in between. This will be helpful for granting permissions, grouping together pre/post-statements, etc.
Similar to this recent PR: https://github.com/TobikoData/sqlmesh/pull/4995
Model config override behavior: model > subfolder > project
Quick and dirty mockup for config.yaml:
model_defaults:
dialect: duckdb
pre_statements:
- "SET timeout = 300000"
post_statements:
- "@IF(@runtime_stage = 'evaluating', ANALYZE @this_model)"
on_virtual_update:
- "GRANT SELECT ON @this_model TO ROLE analyst_role"
subfolder_a:
dialect: snowflake
pre_statements:
- "SET timeout = 200000"
subfolder_b:
pre_statements:
- "SET timeout = 400000"
@themisvaltinos how hard is this given what your recent PR referenced above?
@themisvaltinos how hard is this given what your recent PR referenced above?
This one's a tad trickier for folders, so the implementation would be a bit of a bigger lift. We do now support gateway-specific model defaults, but their resolution happens earlier. So for directory-specific we'd have to structure the loader to support a hierarchical config merging strategy: project → subfolder → model-specific, with proper handling of overrides. So I'd say it’s doable, but not as trivial
+1 for this feature