arnoN7 / dbt-incremental-stream

DBT Package reproducing dbt incremental materialization leveraging on Snowflake streams
MIT License
25 stars 4 forks source link

Posthooks are not executed #11

Closed MarthaScheffler closed 1 month ago

MarthaScheffler commented 1 month ago

When adding a post-hook to an incremental stream model (doesn't matter if it references a source or another model), the post-hook doesn't get executed. Pre-hooks get executed just fine.

code example for testing:


{{ config(
    materialized='incremental_stream',
    pre_hook='CREATE TABLE prehook_works AS SELECT TRUE AS column_1;',
    post_hook='CREATE TABLE posthook_works AS SELECT TRUE AS column_1;'
    ) }}

SELECT *

FROM {{ incr_stream.stream_ref('r__accounts') }} 

I can see that the code for the materialization has two lines for pre-hooks, but just one for post-hooks (inside_transaction=True is missing): https://github.com/arnoN7/dbt-incremental-stream/blob/master/macros/materializations/incremental_stream.sql#L148

arnoN7 commented 1 month ago

Thank you for identifying this issue. The post_hook and pre_hook should both work correctly now. You were absolutely right about the missing line for post-hooks (inside_transaction=True). I’ve added a unit test to ensure this doesn’t regress in the future.

Thanks for spotting this!

MarthaScheffler commented 1 month ago

thank you for the swift fix!