Hooks
Learn how to run additional scripts with hooks.
What are hooks?
Hooks are simply additional SQL statements that dbt can run. This is useful when we want to run some statements that cannot be configured in a standard materialization.
There are four types of hooks:
on-run-start
runs at the start of a dbt command.on-run-end
runs at the end of a dbt command.pre-hook
runs at the start of a model, seed, or snapshot.post-hook
runs at the end of a model, seed, or snapshot.
How to create hooks
Let’s look at how we can edit our project to create hooks.
on-run-start
and on-run-end
To add any of these, an SQL statement can be added to a project or property file. For example, we can run this statement that will set a label to our target dataset.
Get hands-on with 1400+ tech skills courses.