I'm trying to run the run
command with some custom values:
dbt run --vars "{start_date: '2022-08-01', end_date: '2022-08-02'}"
and then use these variables in contexts like:
WHERE session_date BETWEEN {{ var('start_date') }} AND {{ var('end_date') }}
The values need to be inserted as strings (with single quotes kept), but it gets compiled as:
WHERE session_date BETWEEN 2022-08-01 AND 2022-08-02
which then is incorrect SQL ("No matching signature for operator BETWEEN for argument types: DATE, INT64, INT64"). I have tried switching the single and double quotes, but the problem remains.
How can I make it respect the quotes passed in the YAML dict?
I solved this by simply adding single quotes around the variable statements:
WHERE session_date BETWEEN '{{ var("start_date") }}' AND '{{ var("end_date") }}'