Dbt Transformation Patterns

作者 wshobson46891e7e60da無授權條款收錄於 2026年10月8日更新於 2026年10月8日

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.

僅含說明Data & Analytics
AI 產生的概覽

提供 dbt 分析工程模式,涵蓋模型分層、測試、文件與增量處理。

功能
此技能提供建構 dbt 資料轉換專案的指引與慣例。內容涵蓋 medallion 風格的模型分層(staging、intermediate、marts)、命名前綴、範例 dbt_project.yml,以及建議的專案目錄結構。它也列出測試、文件、增量模型和來源資料新鮮度方面的最佳實務,並在參考檔案中提供更詳細的說明。
適用情境
適用於建置或組織 dbt 專案、定義 staging 與 mart 模型、加入資料品質測試,或為大型資料集實作增量模型。也適用於記錄資料模型與血緣關係,或建立 dbt 專案結構。
執行需求
不含指令碼,僅為指引性內容。實際使用 dbt 需要安裝 dbt 並設定資料倉儲連線,但此技能本身只提供指引。

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

LayerPrefixExample
Stagingstg_stg_stripe__payments
Intermediateint_int_payments_pivoted
Martsdim_, fct_dim_customers, fct_orders

Quick Start

yaml
# dbt_project.ymlname: "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 structuremodels/├── 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

來源與署名

來源:wshobson/agents位於plugins/data-engineering/skills/dbt-transformation-patterns提交46891e7

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架