dbt Transformation Patterns

dbt Transformation Patterns

Teaches dbt transformation patterns: staging, intermediate and mart layers, naming, tests, documentation and incremental models for analytics engineers.

Skill files2 files

references/

SKILL.md115 lines
1
---
2
name: dbt-transformation-patterns
3
description: 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.
4
---
5
6
# dbt Transformation Patterns
7
8
Production-ready patterns for dbt (data build tool) including model organization, testing strategies, documentation, and incremental processing.
9
10
## When to Use This Skill
11
12
- Building data transformation pipelines with dbt
13
- Organizing models into staging, intermediate, and marts layers
14
- Implementing data quality tests
15
- Creating incremental models for large datasets
16
- Documenting data models and lineage
17
- Setting up dbt project structure
18
19
## Core Concepts
20
21
### 1. Model Layers (Medallion Architecture)
22
23
```
24
sources/ Raw data definitions
25
↓
26
staging/ 1:1 with source, light cleaning
27
↓
28
intermediate/ Business logic, joins, aggregations
29
↓
30
marts/ Final analytics tables
31
```
32
33
### 2. Naming Conventions
34
35
| Layer | Prefix | Example |
36
| ------------ | -------------- | ----------------------------- |
37
| Staging | `stg_` | `stg_stripe__payments` |
38
| Intermediate | `int_` | `int_payments_pivoted` |
39
| Marts | `dim_`, `fct_` | `dim_customers`, `fct_orders` |
40
41
## Quick Start
42
43
```yaml
44
# dbt_project.yml
45
name: "analytics"
46
version: "1.0.0"
47
profile: "analytics"
48
49
model-paths: ["models"]
50
analysis-paths: ["analyses"]
51
test-paths: ["tests"]
52
seed-paths: ["seeds"]
53
macro-paths: ["macros"]
54
55
vars:
56
start_date: "2020-01-01"
57
58
models:
59
analytics:
60
staging:
61
+materialized: view
62
+schema: staging
63
intermediate:
64
+materialized: ephemeral
65
marts:
66
+materialized: table
67
+schema: analytics
68
```
69
70
```
71
# Project structure
72
models/
73
├── staging/
74
│ ├── stripe/
75
│ │ ├── _stripe__sources.yml
76
│ │ ├── _stripe__models.yml
77
│ │ ├── stg_stripe__customers.sql
78
│ │ └── stg_stripe__payments.sql
79
│ └── shopify/
80
│ ├── _shopify__sources.yml
81
│ └── stg_shopify__orders.sql
82
├── intermediate/
83
│ └── finance/
84
│ └── int_payments_pivoted.sql
85
└── marts/
86
├── core/
87
│ ├── _core__models.yml
88
│ ├── dim_customers.sql
89
│ └── fct_orders.sql
90
└── finance/
91
└── fct_revenue.sql
92
```
93
94
## Detailed patterns and worked examples
95
96
Detailed pattern documentation lives in `references/details.md`. Read that file when the navigation tier above is insufficient.
97
98
## Best Practices
99
100
### Do's
101
102
- **Use staging layer** - Clean data once, use everywhere
103
- **Test aggressively** - Not null, unique, relationships
104
- **Document everything** - Column descriptions, model descriptions
105
- **Use incremental** - For tables > 1M rows
106
- **Version control** - dbt project in Git
107
108
### Don'ts
109
110
- **Don't skip staging** - Raw → mart is tech debt
111
- **Don't hardcode dates** - Use `{{ var('start_date') }}`
112
- **Don't repeat logic** - Extract to macros
113
- **Don't test in prod** - Use dev target
114
- **Don't ignore freshness** - Monitor source data
115

© Seth Hobson · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 11,978 prompts

More by @OpenSourceBuffGuy

See all
Luxury Skincare Vial Product Shot prompt image

Luxury Skincare Vial Product Shot

Renders a luxury skincare commercial photo of a faceted crystal elixir vial on an ivory marble pedestal with orchids and golden droplets, specified as JSON.

image-prompt, json-prompt, gpt-image, product-photography, luxury, photorealistic, studio-lighting, packaging-design, still-life, bokeh, text-rendering, flowers, structured-output, for-marketers, for-designers, low-angle, advertising, beauty, skincare, dramatic-lighting

Black ink doodle portrait with floral border prompt image

Black ink doodle portrait with floral border

Turns a reference photo into a whimsical black ink doodle portrait with a floral doodle border, keeping likeness and expression.

image-prompt, line-art, ink-drawing, doodle, sketch, portrait, face-reference, reference-image, style-transfer, nano-banana, black-and-white, flowers, whimsical, illustration, drawing, avatar, prompt-weights, limited-palette, vertical-format, for-artists, quick

Pixar 3D Character Design Sheet prompt image

Pixar 3D Character Design Sheet

Makes a Pixar-style 3D character sheet pitting a pole vaulter against his vault, with poses, stat bars, a title and a cinematic close-up strip.

image-prompt, gpt-image, pixar-style, 3d-render, character-design, character-sheet, character-consistency, multi-panel, white-background, text-rendering, sports, cartoon, vibrant-colors, cinematic, close-up, man, poster, structured-output, for-artists, for-designers, long-form, humorous

Reviews

Loading reviews…

Discussion

Loading comments…