If you enclose the values
in quotes, then they will be treated as strings by the YAML parser. Otherwise they will be inserted into the query as booleans (which will likely still work, it just means that they will be True
and False
instead of true
and false
.
For example, this SQL and YAML:
--my_model.sql
select true as col1, 1 as id
union all
select false, 2
version: 2
models:
- name: my_model
columns:
- name: col1
tests:
- accepted_values:
values: ['true', 'false']
quote: false
Resolves to this query:
with all_values as (
select
col1 as value_field,
count(*) as n_records
from analytics.dbt_jlabes.my_model
group by col1
)
select *
from all_values
where value_field not in (
true,false
)
So the answer is that you should enclose them in single quotes, but you can do either. I suspect that the column you are testing could be a character varying
type which is why you’re getting errors - the bool is being passed through correctly but the other column is the wrong type.