Feat(dbt): Add support for on-run-start and on-run-end hooks#4044
Feat(dbt): Add support for on-run-start and on-run-end hooks#4044themisvaltinos merged 5 commits intomainfrom
Conversation
erindru
left a comment
There was a problem hiding this comment.
Looks good to me!
I'm not 100% on how the JinjaMacroRegistry is meant to be constructed but the tests look like they're exercising the right things
52da5f5 to
695d0b1
Compare
Thanks for drawing my attention to it! I took a closer look and extended the implementation to also account for multiple projects when constructing and adding the jinja macros to the registry |
695d0b1 to
4a8c2a1
Compare
| for project in self._load_projects(): | ||
| context = project.context.copy() | ||
| if manifest := context._manifest: | ||
| on_run_start.extend(manifest._on_run_start or []) |
There was a problem hiding this comment.
If we access these outside the manifest instance, we shouldn't mark them as private. Or at the very least add a public property method to expose these.
| *(gen(stmt) for stmt in statements) | ||
| ) | ||
| jinja_macros = context.jinja_macros | ||
| jinja_macros.root_macros = jinja_root_macros |
There was a problem hiding this comment.
Why do we do this gymnastics with root macros?
This update adds support for dbt's
on-run-startandon-run-endhooks which are defined indbt_project.yml:Internally, these are mapped to SQLMesh's
before_allandafter_allstatementsAs part of this update, the
schemasvariable is also supported, enabling to grant privileges as you would in dbt with a macro:This macro can then be used in
on-run-end:This is also supported in native SQLMesh projects for
before_allandafter_allstatements:And by defining the corresponding macro: