Hello I would like to ask for your assistance I'm planning to validate my age field on database however I'm not sure how to make it work on DBT. Your response is highly appreciated. Thank you
- name: age
tests:
- not_null
# - dbt_expectations.expect_column_values_to_match_regex:
# regex: "[1-9]\\d{3,}"
# - dbt_utils.not_empty_string
# - dbt_utils.not_constant
- dbt_utils.expression_is_true:
expression: "age"
config:
where: "age > '110'"
I tried to use this syntax below however its not working and the complied statement showed.
- name: age
tests:
- not_null
# - dbt_expectations.expect_column_values_to_match_regex:
# regex: "[1-9]\\d{3,}"
# - dbt_utils.not_empty_string
# - dbt_utils.not_constant
- dbt_utils.expression_is_true:
expression: '>= 110'
Result:
You're really close! In dbt tests, you write what you want to pass the test and (for this test) then it puts
not(<expression>)
to find the rows that fail the test.Because of that, this should do it: