The problem I’m having
Date variable provided in command line is not flowing through to code, resulting in braced constructors are not supported error in BigQuery.
The context of why I’m trying to do this
Refrencing dbt insert_overwrite strategy with static partitions. I want to add an if else block to set the partitions_to_replace.
What I’ve already tried
{% if var("date", false) != false %}
{% set partitions_to_replace = [
'{{ var("date") }}',
] %}
{% else %}
{% set partitions_to_replace = [
'current_date',
'date_sub(current_date, interval 1 day)',
'date_sub(current_date, interval 2 day)',
'date_sub(current_date, interval 3 day)'
] %}
{% endif %}
dbt command line
dbt run -s test_model --vars '{date: 2023-07-03}'
Error
WHERE
DATE(timestamp_modified) IN ({{ var("date") }})
) as DBT_INTERNAL_SOURCE
on FALSE
when not matched by source
and date(DBT_INTERNAL_DEST.date_modified) in (
{{ var("date") }}
)
then delete
when not matched then insert
(`timestamp_modified`, `date_modified`, `reference`)
values
(`timestamp_modified`, `date_modified`, `reference`)