tags

info

To tag a column, test, or source, use the tag property.

dbt_project.yml
models:
+tags: <string> | [<string>]
snapshots:
+tags: <string> | [<string>]
seeds:
+tags: <string> | [<string>]

Definition

Apply a tag (or list of tags) to a model, seed, or snapshot.

These tags can be used as part of the resource selection syntax, when running the following commands:

  • dbt run --models tag:my_tag
  • dbt seed --select tag:my_tag
  • dbt snapshot --select tag:my_tag

Note that you need to use the tag property to apply tags to columns, tests, and sources. (Yes, we know this is confusing, and hope to resolve it in a future release!)

Examples

Use tags to run parts of your project

Apply tags in your dbt_project.yml as a single value or a string:

dbt_project.yml
models:
jaffle_shop:
+tags: "contains_pii"
staging:
+tags:
- "hourly"
marts:
+tags:
- "hourly"
- "published"
metrics:
+tags:
- "daily"
- "published"

You can also apply tags to individual resources using a config block:

models/staging/stg_payments.sql
{{ config(
tags=["finance"]
) }}
select ...

Then, run part of your project like so:

# Run all models tagged "daily"
$ dbt run --model tag:daily
# Run all models tagged "daily", except those that are tagged hourly
$ dbt run --model tag:daily --exclude tag:hourly

Apply tags to seeds

dbt_project.yml
seeds:
jaffle_shop:
utm_mappings:
+tags: marketing
dbt_project.yml
seeds:
jaffle_shop:
utm_mappings:
+tags:
- marketing
- hourly

Usage notes

Tags are additive

Tags accumulate hierarchically. The above example would result in:

ModelTags
models/staging/stg_customers.sqlcontains_pii, hourly
models/staging/stg_payments.sqlcontains_pii, hourly, finance
models/marts/dim_customers.sqlcontains_pii, hourly, published
models/metrics/daily_metrics.sqlcontains_pii, daily, published