Please, help me how it pass macro value to config partitions?
./macros/partitions_to_replace.sql
{% macro partitions_to_replace_eiei() %}
{% set is_lastday_of_month = run_query("SELECT IF(LAST_DAY(current_date()) = current_date(), 1, 0)") %}
{% if execute %}
{{ print(is_lastday_of_month[0].values()) }}
{% if is_lastday_of_month.columns[0].values()|int == 0 %}
{{ return(['current_date',
'date_sub(current_date, interval 1 day)']) }}
{% else %}
{% set where_sql = [] %}
{% for i in range(1,36) %}
{{ where_sql.append('date_sub(current_date, interval '+i|string+' day)') }}
{% endfor %}
{{ return(where_sql) }}
{% endif %}
{% endif %}
{% endmacro %}
./model/test.sql
{% set partitions_to_replace = partitions_to_replace_eiei() %}
{{
config(
database="gillcapital-datalake",
materialized="incremental",
partition_by = {'field': 'order_date', 'data_type': 'timestamp','granularity': 'day'},
incremental_strategy='insert_overwrite',
partitions= partitions_to_replace
)
}}
./target/run/partitions_to_replace/models/test.sql
SELECT id,
user_id,
order_date,
status
FROM `test_project.z_test_dbt.raw_order`
WHERE timestamp_trunc(order_date, day) in (current_date,date_sub(current_date, interval 1 day))
) as DBT_INTERNAL_SOURCE
on FALSE
when not matched by source
and timestamp_trunc(DBT_INTERNAL_DEST.order_date, day) in (
,
, , , , ,
, , , , ,
,
,
)
then delete
when not matched then insert
(`id`, `user_id`, `order_date`, `status`)
values
(`id`, `user_id`, `order_date`, `status`)