dbt Variables

dbt Variables #

Defining variables #

From dbt_project #

To define variables in dbt_project.yml:

vars:
    <variable name>: <value>
        

Specified variables can be accessed from models (i.e., sql files) with:

    ... '{{ var('<variable name>') }}'

From the Command Line #

To define variables from the command line:

dbt run --vars '{<key>:<value>, <key>:<value>}'

^ Brackets are optional if there’s only one variable.

Command line variables take precedence over dbt_project.yml variables.