Working with Tags in your dbt™️ Project
Overview
Tags in dbt™️ are powerful metadata identifiers that can be applied to various resources in your dbt™️ project. They enable flexible resource selection and help organize your project components. This guide covers how to implement and use tags effectively in your dbt™️ projects.
Implementation Methods
1. Config Property
The config property allows you to apply tags directly to individual resources using a config block in your SQL files.
2. Config Block in dbt_project.yml
Tags can be applied at various levels in your dbt_project.yml
file, affecting multiple resources hierarchically.
Key Features
Tag Inheritance and Hierarchy
Tags are additive and accumulate hierarchically. Resources inherit tags from their parent folders and can have additional tags applied directly.
Example inheritance:
Resource Type Support
Tags can be applied to multiple resource types:
Models
Snapshots
Seeds
Other Resources (in schema.yml)
CLI Usage
Basic Selection
Advanced Selection
Best Practices
Consistent Naming: Use consistent tag naming conventions across your project
Documentation: Document your tagging strategy in your project's README
Granular Tags: Use specific tags rather than overly broad ones
Layer-Based Tags: Consider using tags to denote your data modeling layers
Common Use Cases
Refresh Schedules
Data Classification
Testing Strategies
Troubleshooting
Tag Inheritance Issues
Check parent folder configurations in dbt_project.yml
Verify tag syntax and formatting
Use
dbt ls
to verify applied tags
Selection Syntax
Ensure tag names match exactly (case-sensitive)
Check for proper quoting in command line arguments
Verify tag exists in project using
dbt ls
Remember that tags are a powerful organizational tool, but they should be used thoughtfully and consistently across your project for maximum benefit.
Last updated