dbt-transformation-patterns
它能做什么
这个工具可以帮你组织和测试用于分析的数据。它介绍了如何把数据分成多个层次(例如 “staging”“intermediate”“marts”),并统一文件命名方式,让数据更容易理解。
适用场景
- ✓当你开始为分析整理数据时。
- ✓当你要为报表创建最终数据表时。
- ✓当你的数据量很大,希望更高效地处理时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/data-engineering/skills/dbt-transformation-patterns/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我怎样使用 Medallion 架构来组织数据?”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会推荐一套文件夹结构,并为每一层(staging、intermediate、marts)指定名称。它还会给出数据文件的命名示例,让所有人都能看懂每个文件代表什么。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
dbt Transformation Patterns
Production-ready patterns for dbt (data build tool) including model organization, testing strategies, documentation, and incremental processing.
When to Use This Skill
- Building data transformation pipelines with dbt
- Organizing models into staging, intermediate, and marts layers
- Implementing data quality tests
- Creating incremental models for large datasets
- Documenting data models and lineage
- Setting up dbt project structure
Core Concepts
1. Model Layers (Medallion Architecture)
sources/ Raw data definitions
↓
staging/ 1:1 with source, light cleaning
↓
intermediate/ Business logic, joins, aggregations
↓
marts/ Final analytics tables
2. Naming Conventions
| Layer | Prefix | Example |
|---|---|---|
| Staging | stg_ |
stg_stripe__payments |
| Intermediate | int_ |
int_payments_pivoted |
| Marts | dim_, fct_ |
dim_customers, fct_orders |
Quick Start
# dbt_project.yml
name: "analytics"
version: "1.0.0"
profile: "analytics"
model-paths: ["models"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
seed-paths: ["seeds"]
macro-paths: ["macros"]
vars:
start_date: "2020-01-01"
models:
analytics:
staging:
+materialized: view
+schema: staging
intermediate:
+materialized: ephemeral
marts:
+materialized: table
+schema: analytics
# Project structure
models/
├── staging/
│ ├── stripe/
│ │ ├── _stripe__sources.yml
│ │ ├── _stripe__models.yml
│ │ ├── stg_stripe__customers.sql
│ │ └── stg_stripe__payments.sql
│ └── shopify/
│ ├── _shopify__sources.yml
│ └── stg_shopify__orders.sql
├── intermediate/
│ └── finance/
│ └── int_payments_pivoted.sql
└── marts/
├── core/
│ ├── _core__models.yml
│ ├── dim_customers.sql
│ └── fct_orders.sql
└── finance/
└── fct_revenue.sql
Detailed patterns and worked examples
Detailed pattern documentation lives in references/details.md. Read that file when the navigation tier above is insufficient.
Best Practices
Do's
- Use staging layer - Clean data once, use everywhere
- Test aggressively - Not null, unique, relationships
- Document everything - Column descriptions, model descriptions
- Use incremental - For tables > 1M rows
- Version control - dbt project in Git
Don'ts
- Don't skip staging - Raw → mart is tech debt
- Don't hardcode dates - Use
{{ var('start_date') }} - Don't repeat logic - Extract to macros
- Don't test in prod - Use dev target
- Don't ignore freshness - Monitor source data
常见问题
“staging”“intermediate”和“marts”层分别是什么?
它们可以理解为整理数据的几个步骤。“staging”用于最初的清洗,“intermediate”是应用业务逻辑的地方,“marts”则是可以直接用于分析的最终数据表。
为什么要测试数据?
测试可以确保数据正确且完整,避免之后的报表和分析出现错误。
“incremental”是什么意思?
意思是每次不必处理全部数据,只处理新增或有变化的数据。对于大量数据来说,这样要快得多。
详情
作者的原始描述
Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6671
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …