Skip to content

Commit

Permalink
General examples of calling a macro in a hook
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 authored Aug 23, 2024
1 parent 1be2036 commit a40e111
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions website/docs/docs/build/hooks-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ You can use hooks to provide database-specific functionality not available out-o

You can also use a [macro](/docs/build/jinja-macros#macros) to bundle up hook logic. Check out some of the examples in the reference sections for [on-run-start and on-run-end hooks](/reference/project-configs/on-run-start-on-run-end) and [pre- and post-hooks](/reference/resource-configs/pre-hook-post-hook).

<File name='models/<model_name>.sql'>

```sql
{{ config(
pre_hook="{{ some_macro() }}"
) }}

select 1 as id
```

</File>

<File name='dbt_project.yml'>

```sql
models:
<project_name>:
+pre-hook: "{{ some_macro() }}"
```

</File>

## About operations

Operations are [macros](/docs/build/jinja-macros#macros) that you can run using the [`run-operation`](/reference/commands/run-operation) command. As such, operations aren't actually a separate resource in your dbt project — they are just a convenient way to invoke a macro without needing to run a model.
Expand Down

0 comments on commit a40e111

Please sign in to comment.