From a778c63421073264dc7cabc558be624a2af9b3fd Mon Sep 17 00:00:00 2001 From: Sam Debruyn Date: Tue, 19 May 2026 10:45:49 +0200 Subject: [PATCH] Override run_hooks so pre/post hooks do not emit commit; The default run_hooks macro from dbt-adapters emits a bare commit; between hook batches outside the implicit transaction. Fabric Warehouse does not support BEGIN/COMMIT TRAN, so every project using pre-hook or post-hook fails at the run boundary. Add a Fabric-local run_hooks override that drops the commit; statement while preserving the rest of the hook execution logic. --- dbt/include/fabric/macros/materializations/hooks.sql | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 dbt/include/fabric/macros/materializations/hooks.sql diff --git a/dbt/include/fabric/macros/materializations/hooks.sql b/dbt/include/fabric/macros/materializations/hooks.sql new file mode 100644 index 00000000..39bf2d74 --- /dev/null +++ b/dbt/include/fabric/macros/materializations/hooks.sql @@ -0,0 +1,10 @@ +{% macro run_hooks(hooks, inside_transaction=True) %} + {% for hook in hooks | selectattr('transaction', 'equalto', inside_transaction) %} + {% set rendered = render(hook.get('sql')) | trim %} + {% if (rendered | length) > 0 %} + {% call statement(auto_begin=inside_transaction) %} + {{ rendered }} + {% endcall %} + {% endif %} + {% endfor %} +{% endmacro %}