Model groups
Groups
Models can be grouped under a common designation with a shared owner. For example, you could group together all models owned by a particular team, or related to modeling a specific data source (hubspot).
Groups transforms implicit relationships into explicit groupings with a defined owner. By defining interface boundaries between groups, you can create a cleaner, less entangled DAG.
This approach allows you to designate certain models as having "private" access, intended for exclusive use within that group. Other models will be restricted from referencing or depending on these private models. Eventually, these private models won't be visible to other teams relying on your project—only the "public" models will be accessible.
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.
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: [email protected]
      slack: finance-data
      github: finance-data-teamAdding a model to a group
Use the group configuration to add one or more models to a group.
models:
  marts:
    finance:
      +group: financemodels:
  - 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: marketingmodels:
  - name: finance_private_model
    access: private
    config:
      group: finance
  # in a different group!
  - name: marketing_model
    config:
      group: marketingLast updated
Was this helpful?