Project Variables

Project variables are a good way to define and store some configuration values that can be used across the whole project. They’re especially useful to define default values in our project.

Defining variables in the project.yml file

Let’s say we’re managing dbt projects for a chain of stores. Each store is likely to have a similar dbt project, except that their name and identifier are different.

We can define shop_name and shop_id as project variables to avoid having to hardcode those values in every model and macro that we have.

To define project variables, we have to nest them inside a vars key in our dbt-project.yml file:

Get hands-on with 1200+ tech skills courses.