Nesting of vars in dbt_project.yml

Hello,

I’m unable to access directly indented variables in my models, that are defined in the vars from project.yml.

vars:
  topic_group:
    var_in_topic_1: value_1
    var_in_topic_2: value_2

I’d like to be able to access directly the nested variable var_in_topic_1 inside my model.
Something like:

SELECT {{ var('topic_group.var_in_topic_1') }} AS CONFIG_VALUE_1

I keep getting variable not defined errors, I’ve tried a few methods for calling it.

But, I actually found the solution while writing the question:

SELECT {{ var('topic_group')['var_in_topic_1'] }} AS CONFIG_VALUE_1

The var in this case returns some kind of dict object that can be then used inside the curlies.

That works for me, I leave this here as it might help another newbie like me.

How can we override such nested variable {{ var('topic_group')['var_in_topic_1'] }} via command line?

Good follow-up question.
I don’t know, I’ve tried a few methods and I’m not finding a way to override specifically the nested variable without rewriting the full dictionary"topic_group".