I have a variable that I need to re-use in different files, and I have trouble importing it. E.g. several hundred lines of:
{% set auto_curated_columns = { “oldname”:“newname”, “old_col_2”:“new_col_2”} %}
I would like to do
{% from ‘file_with_definition’ import auto_curated_columns %}
but that errors out with: “no loader for this environment specified”.
Vars defined in dbt_project.yaml is not a good fit extensive implementation details should really not go there.
It wouldn’t even fit into an environment variable.
A template would not cut it - I am using the variable in loops, conditionals, to derive code, to derive column names such as import_status_of_{{auto_curated_columns.loop}}, etc. (Sticking the file with the definitions into the macros directory doesn’t work either.)
For now, I’m stuck pasting the variable definition into tests and yaml-files. At least for models, I can define vars:auto_curated_columns in dbt_project.yml and then {{ set auto_curated_columns = fromjson(var(‘auto_curated_columns’))}}.
How do I import a variable directly, instead?
How do I use Jinja in schema.yml?