Mert Kucukkuru
07/19/2024, 8:58 AMvar('channel_id_fin'). I am able to use it in .sql files with the same syntax but not in the yml files.Marie TENAUD
07/19/2024, 11:38 AM{{var('businessUnitIdentifier', '015')}}
but when running a dbt command, it will take the right value, but it still needs a default one to workMert Kucukkuru
07/19/2024, 11:39 AMMarie TENAUD
07/19/2024, 11:45 AMmodels:
internalDataProcessing:
+database: "{{ target.project }}"
+persist_docs:
relation: true
columns: true
local:
+enabled: "{{var('businessUnitIdentifier', '005') != '015'}}"
+materialized: table
staging:
+schema: "ds_internalDataProcessing"
materialized: table
intermediate:
+schema: "dl_internalDataProcessing"
materialized: table
publish:
+schema: "internalDataProcessing"
materialized: table
global:
+enabled: "{{var('businessUnitIdentifier', '015') == '015'}}"
+schema: "internalDataProcessing"
materialized: table
vars:
"businessUnitIdentifier": "003"
My goal here was to execute models of folder "local" only if my businessUnitIdentifier was not equal to 015, and execute "global" folder only in 015 case.
My issue is that writing {{var('businessUnitIdentifier')}} in the dbt_project.yml got me an error that it did not know the value of businessUnitIdentifier. So I put the default value "015" so it does not bring me issue. But that still did not bother me to run my models and get the right default var "003" (and when wanting 015, I ran dbt run --vars '{"businessUnitIdentifier":"015"}' to execute only the global folder)
Hope my use case is clear enough for you !