All,
I am putting together a POC using dbt at work.
We are a bit stuck at the moment tbh and wondering if there are pointers someone here can give us.
We are looking to call a few macros within the post_hook
that works well
{{- config(
post_hook = [macro1(), macro2()]
) -}}
Macro2 needs to be outside of the transaction as it refers to the model being created and this is causing issues in the first run. I attempted to try it out like below but that didn’t really work
post_hook = after_commit(macro2())
However, calling by changing to plain sql worked
post_hook = {"sql": "insert into table from {{ this }}", "transaction": False}
This got me looking into the dbt project on Github, where I see
{% macro make_hook_config(sql, inside_transaction) %}
{{ tojson({"sql": sql, "transaction": inside_transaction}) }}
{% endmacro %}
{% macro after_commit(sql) %}
{{ make_hook_config(sql, inside_transaction=False) }}
{% endmacro %}
Does this mean I can only call sql statements within after_commit? Is there any way I can set transaction per macro level since my post_hook looks so - post_hook = [macro1(), macro2()]
?
Appreciate your help, thanks.