I would like to declare and init a variable in a dbt model customer.sql
file.
I used the keyword DECLARE
to declare a variable like the BigQuery documentation suggests but I got
a Syntax error
on DECLARE
keyword.
Code:
DECLARE myDate VARCHAR DEFAULT '2021-01-01';
with order_bis as (
select
order_id
from
order
where
customer_date > myDate
)
select * from order_bis
Error:
Syntax error: Expected "(" or keyword SELECT or keyword WITH but got keyword DECLARE ...
{% set myVar = '2017-01-01' %} select {{ myVar }}
yields2015
. The query may run, but it's not doing what you want – Hirohito