Here is post hook for dbt model: {{ config( post_hook=[ '{{ execute_if_exists("delete from " ~ this ~ " where day = date('' " ~ var("mydatevar") ~ " '')") }}', ] ) }} Please note the '' in the string. Next: {% macro execute_if_exists(query) -%} {{ query }} {%- endmacro %} And I got delete from catalog.myschema.mytable where day = date( 2024-10-02 ) While expected is: delete from catalog.myschema.mytable where day = date(' 2024-10-02 ') I have tried \' and got error. I have switched " and ' again no effect. UPDATED '{{ execute_if_exists("delete from " ~ this ~ " where day = date(' " ~ var("mydatevar") ~ " ')") }} - compilation error "{{ execute_if_exists('delete from ' ~ this ~ ' where day = date(' ' ~ var('mydatevar') ~ ' ')') }}" - same effect "{{ execute_if_exists('delete from ' ~ this ~ ' where day = date(' ' ~ var('mydatevar') ~ ' ')') }}" - also compilation error Continue reading...