Hello
@joellabes
Iam Unable to used the variable defined in dbt_project.yml in the same file.
I have defined the variable in dbt_project.yml file as below
vars:
gcp_project_id: ‘gcp-dev-sandbox’
local_time_zone: ‘Europe/London’
dag_id: “customers_load”
I want to use the the variable dag_id to create target folder as below
target-path: “target/{{ var(‘dag_id’) }}”
When i run it as below it fail’s
→ dbt run --select tag:customers_load
File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/utils.py”, line 196, in _deep_map_render
ret = func(value, keypath)
File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/config/renderer.py”, line 143, in render_entry
result = super().render_entry(value, keypath)
File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/config/renderer.py”, line 33, in render_entry
return self.render_value(value, keypath)
File “/opt/homebrew/Cellar/dbt-bigquery/1.2.0/libexec/lib/python3.9/site-packages/dbt/config/renderer.py”, line 45, in render_value
raise CompilationException(msg) from exc
dbt.exceptions.CompilationException: Compilation Error
Could not render target/{{ var(‘dag_id’) }}: Required var ‘dag_id’ not found in config:
Vars supplied to = {}
09:46:53 Encountered an error:
Compilation Error
Could not render target/{{ var(‘dag_id’) }}: Required var ‘dag_id’ not found in config:
Vars supplied to = {}
Alternatively
i need to run it to pass the variable in dbt run , this make life complex as we need to pass var for each run if we are doing to test locally.
→ dbt run --select tag:customers_load --vars {“dag_id”: “customers_load”}