Add groups to your DAG
A group is a collection of nodes within a dbt DAG. Groups are named, and every group has an owner
. They enable intentional collaboration within and across teams by restricting access to private models.
Group members may include models, tests, seeds, snapshots, analyses, and metrics. (Not included: sources and exposures.) Each node may belong to only one group.
Declaring a group
Groups are defined in .yml
files, nested under a groups:
key.
groups:
- name: finance
owner:
# 'name' or 'email' is required; additional properties allowed
email: finance@jaffleshop.com
slack: finance-data
github: finance-data-team
Adding a model to a group
Use the group
configuration to add one or more models to a group.
- Project-level
- Model-level
- In-file
models:
marts:
finance:
+group: finance
models:
- name: model_name
config:
group: finance
{{ config(group = 'finance') }}
select ...
Referencing a model in a group
By default, all models within a group have the protected
access modifier. This means they can be referenced by downstream resources in any group in the same project, using the ref
function. If a grouped model's access
property is set to private
, only resources within its group can reference it.
models:
- name: finance_private_model
access: private
config:
group: finance
# in a different group!
- name: marketing_model
config:
group: marketing
select * from {{ ref('finance_private_model') }}
$ dbt run -s marketing_model
...
dbt.exceptions.DbtReferenceError: Parsing Error
Node model.jaffle_shop.marketing_model attempted to reference node model.jaffle_shop.finance_private_model,
which is not allowed because the referenced node is private to the finance group.