Apply Multiple Macros as Hooks on a Model

Hello,

I’m currently trying to develop a model to which i want to deploy some quality checks in terms of data quality. The thing is, as it stands i can’t address on post_hook more than one macro. How can i work around this to reference multiple macros in the same model?

Example:
post_hook=“{{ Macro1(Arg1, Arg2,Arg3) }},{{ Macro2(Arg4, Arg5,Arg6,Arg7) }}”

Thank you.

Hey @jpgsa11! To call multiple macros, you should pass each one in as its own element of a list:

--some_model.sql
{{ config(
  post_hook=[
    "{{ Macro1(Arg1, Arg2, Arg3) }}",
    "{{ Macro2(Arg4, Arg5, Arg6, Arg7) }}"
  ]
)}}

For more details check out the docs on hooks: pre-hook & post-hook | dbt Developer Hub

2 Likes

It’s worth noting that the default way to do this is to use dbt tests, not post-hooks. If you haven’t looked into tests much, keep in mind that you can create your own tests, which are just SQL queries that return failing rows: Writing custom generic tests | dbt Developer Hub

1 Like

True and thank you for the advice, but i want to store logs of test execitions and the results combined in one table alone, instead of the default way to generate an automatic table with the results. So the focus is to centralize the results and logs of executions. Only workaround i found was to create a macro and do this myself. If you have any suggestions regarding this, please

Depending on the level of granularity you need from executions and results, using the dbt_artifacts package might work for you. it will create a table with a row for each test invocation and its outcome (but doesn’t include all of the failing rows for example.)

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.