I am trying to call 1 macro from a pre_hook in a model. That macro shall contain multiple delete statements but dbt is unable to parse it.
What is the ideal way to do this?
I’ve tried using the below in config but it didn’t work.
pre_hook=“{{ process_delete().split(‘;’) }}”
Some example code or error messages
{% macro process_delete() %}
delete
from schmea.table1
where ((column1= True)
and column2 is null);
delete
from schema.table1
where (column3,column4) in (select xyz, sst
from schema.table1
where column3 is not null)
and column5 is null;
{% endmacro %}
error:
[PARSE_SYNTAX_ERROR] Syntax error at or near ‘[’.(line 3, pos 8)
['\ndelete\nfrom schema.table1
if you are using a macro in post-hook the macro should return an sql query
{% macro process_delete() %}
{% set query %}
delete
from schmea.table1
where ((column1= True)
and column2 is null);
delete
from schema.table1
where (column3,column4) in (select xyz, sst
from schema.table1
where column3 is not null)
and column5 is null;
{% endset %}
{{ return(query) }}
{% endmacro %}