Hello All,
I want to use variables defined in the dbt_project.yml in definition.yml for testing the models.
But so far these variables are not being recognized when running the test cases using dbt test -m <model_name>
Is there are way to access variables in definition.yml ?
My code looks like this
dbt_project.yml
name: 'first_dbt_project'
version: '1.0.0'
# This setting configures which "profile" dbt uses for this project.
profile: default
config-version: 2
source-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
clean-targets:
- "target"
- "dbt_modules"
vars:
runDate: 20210131
intakeDate: 202106
definition.yml
version: 2
models:
- name: first_model
tests:
- dbt_utils.expression_is_true:
expression: "len(machine_id) between 8 and 9 "
where: "rundate > {{ var('rundate')}}"