Summary
The adapter ships no materializations/hooks.sql, so dbt-adapters' default run_hooks macro runs unchanged. That default emits commit; to exit the implicit transaction wrapping a model. Fabric Warehouse does not support BEGIN/COMMIT TRAN. Every project that uses pre-hook or post-hook therefore fails at every run boundary.
Evidence (HEAD 0de2190, v1.10.0)
dbt/include/fabric/macros/materializations/ contains models/, snapshots/, seeds/, snapshot/, but no hooks.sql:
git ls-tree 0de2190 dbt/include/fabric/macros/materializations/ --name-only
# models/
# snapshot/
# snapshots/
# seeds/
No run_hooks override exists. dbt-adapters' default — at dbt/include/global_project/macros/materializations/hooks.sql — calls commit; between hook batches.
Reproduction
Add any pre-hook or post-hook to a model in a Fabric DW dbt project:
# dbt_project.yml
models:
my_project:
+pre-hook:
- "select 1"
Run dbt run. The hook block fails with a T-SQL error around commit;.
User impact
pre-hook / post-hook is a core dbt feature (docs). Any project using it on Fabric Warehouse cannot run unmodified.
Suggested fix
Add dbt/include/fabric/macros/materializations/hooks.sql overriding run_hooks (the dbt-adapters macro is not dispatched, so the override is by name):
{% 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 %}
This is the same pattern dbt-athena uses to drop the commit; for engines without transactional DDL semantics (reference).
A working version of this fix is running in the sdebruyn/dbt-fabric fork — commit 62705a00. A PR against this repo will follow.
Summary
The adapter ships no
materializations/hooks.sql, so dbt-adapters' defaultrun_hooksmacro runs unchanged. That default emitscommit;to exit the implicit transaction wrapping a model. Fabric Warehouse does not supportBEGIN/COMMIT TRAN. Every project that usespre-hookorpost-hooktherefore fails at every run boundary.Evidence (HEAD
0de2190, v1.10.0)dbt/include/fabric/macros/materializations/containsmodels/,snapshots/,seeds/,snapshot/, but nohooks.sql:No
run_hooksoverride exists. dbt-adapters' default — atdbt/include/global_project/macros/materializations/hooks.sql— callscommit;between hook batches.Reproduction
Add any
pre-hookorpost-hookto a model in a Fabric DW dbt project:Run
dbt run. The hook block fails with a T-SQL error aroundcommit;.User impact
pre-hook/post-hookis a core dbt feature (docs). Any project using it on Fabric Warehouse cannot run unmodified.Suggested fix
Add
dbt/include/fabric/macros/materializations/hooks.sqloverridingrun_hooks(the dbt-adapters macro is not dispatched, so the override is by name):This is the same pattern
dbt-athenauses to drop thecommit;for engines without transactional DDL semantics (reference).A working version of this fix is running in the
sdebruyn/dbt-fabricfork — commit62705a00. A PR against this repo will follow.