I have a variable and I want to pass it to a macros, I call the macros itself in pre_Hook
{% set v_name = 'BOS' %}
{{
config(
pre_hook=[
"{{marcos_test(v_name)}}"
]
)
}}
it works, but in the macros itself it does not see the value of the variable
How can I call marcos in pre_hook so it will see the value of the variable ? Global variable in dbt_project.yml file they are not suitable because I need a dynamic variable
someone please help
One way to achieve this is to use concatenation. You can use ~
sign for concatenation in Jinja.
Note, your macro most probably expects string as an input, then you need to add '
quotes around concatenation (...'" ~ v_name ~ "'...
).
{% set v_name = 'BOS' %}
{{
config(
pre_hook=[
"{{ marcos_test('" ~ v_name ~ "') }}"
]
)
}}