group
New functionality
This functionality is new in v1.5.
- Models
- Seeds
- Snapshots
- Tests
- Analyses
- Metrics
models/schema.yml
version: 2
models:
- name: model_name
group: finance
dbt_project.yml
models:
<resource-path>:
+group: finance
models/<modelname>.sql
{{ config(
group='finance'
) }}
select ...
dbt_project.yml
models:
<resource-path>:
+group: finance
seeds/properties.yml
seeds:
- name: [<seed-name>]
group: finance
dbt_project.yml
snapshots:
<resource-path>:
+group: finance
snapshots/<filename>.sql
{% snapshot snapshot_name %}
{{ config(
group='finance'
) }}
select ...
{% endsnapshot %}
dbt_project.yml
tests:
<resource-path>:
+group: finance
tests/properties.yml
version: 2
<resource_type>:
- name: <resource_name>
tests:
- <test_name>:
config:
group: finance
tests/<filename>.sql
{% test <testname>() %}
{{ config(
group='finance'
) }}
select ...
{% endtest %}
tests/<filename>.sql
{{ config(
group='finance'
) }}
analyses/<filename>.yml
version: 2
analyses:
- name: <analysis_name>
group: finance
dbt_project.yml
metrics:
<resource-path>:
+group: finance
models/metrics.yml
version: 2
metrics:
- name: [<metric-name>]
group: finance
Definition
An optional configuration for grouping models, analysis, snapshots, tests, and metrics. When a resource is grouped, dbt will allow it to reference private models within the same group.
For more details on reference access between resources in groups, check out model access.
Examples
Prevent a 'marketing' group model from referencing a private 'finance' group model
This is useful if you want to prevent other groups from building on top of models that are rapidly changing, experimental, or otherwise internal to a group or team.
models/schema.yml
models:
- name: finance_model
access: private
group: finance
- name: marketing_model
group: marketing
models/marketing_model.sql
select * from {{ ref('finance_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_model,
which is not allowed because the referenced node is private to the finance group.
Related docs
0