‹ 首页

debugging-dbt-errors

@altimateai · 收录于 1 周前

Debugs and fixes dbt errors systematically. Use when working with dbt errors for: (1) Task mentions "fix", "error", "broken", "failing", "debug", "wrong", or "not working" (2) Compilation Error, Database Error, or test failures occur (3) Model produces incorrect output or unexpected results (4) Need to troubleshoot why a dbt command failed Reads full error, checks upstream first, runs dbt build (not just compile) to verify fix.

适合你,如果经常遇到 dbt 编译或运行错误需要快速定位修复

/ 下载安装
debugging-dbt-errors.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add altimateai/data-engineering-skills/debugging-dbt-errors
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- altimateai/data-engineering-skills/debugging-dbt-errors
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify altimateai/data-engineering-skills/debugging-dbt-errors
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
109GitHub stars
~937上下文体积 · 单文件
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · a13847e

dbt Troubleshooting

Read the full error. Check upstream first. ALWAYS run dbt build after fixing.

Critical Rules
  1. ALWAYS run dbt build after fixing - compile is NOT enough to verify the fix
  2. If fix fails 3+ times, stop and reassess your entire approach
  3. Verify data after build - build passing doesn't mean output is correct
Workflow
1. Get the Full Error
dbt compile --select <model_name>
# or
dbt build --select <model_name>

Read the COMPLETE error message. Note the file, line number, and specific error.

2. Inspect Actual Data (For Data Issues)

Before fixing "wrong output" or "incorrect results", query the actual data:

# Preview current output
dbt show --select <model_name> --limit 20

# Check specific values with inline query
dbt show --inline "select * from {{ ref('model_name') }} where <condition>" --limit 10

# Compare with expected - look for patterns
dbt show --inline "select column, count(*) from {{ ref('model_name') }} group by 1 order by 2 desc" --limit 10

Understand what's wrong before attempting to fix it.

3. Read Compiled SQL
cat target/compiled/<project>/<path>/<model_name>.sql

See the actual SQL that will run.

4. Analyze Error Type

| Error Type | Look For | |------------|----------| | Compilation Error | Jinja syntax, missing refs, YAML issues | | Database Error | Column not found, type mismatch, SQL syntax | | Dependency Error | Missing model, circular reference |

5. Check Upstream Models
# Find what this model references
grep -E "ref\(|source\(" models/<path>/<model_name>.sql

# Read upstream model to verify columns
cat models/<path>/<upstream_model>.sql

Many errors come from upstream changes, not the current model.

6. Apply Fix

Common fixes:

| Error | Fix | |-------|-----| | Column not found | Check upstream model's output columns | | Ambiguous column | Add table alias: table.column | | Type mismatch | Add explicit CAST() | | Division by zero | Use NULLIF(divisor, 0) | | Jinja error | Check matching {{ }} and {% %} |

7. Rebuild (MANDATORY)
dbt build --select <model_name>

3-Failure Rule: If build fails 3+ times, STOP. Step back and:

  1. Re-read the original error
  2. Check if your entire approach is wrong
  3. Consider alternative solutions
8. Verify Fix
# Preview the data
dbt show --select <model_name> --limit 10

# Run tests
dbt test --select <model_name>
9. Re-review Logic Against Requirements

After fixing, re-read the original request and verify:

  • Does the output match what the user asked for?
  • Are the column names exactly as requested?
  • Is the calculation logic correct per the requirements?
  • Did you solve the actual problem, not just make the error go away?
10. Check Downstream Impact
# Find downstream models
grep -r "ref('<model_name>')" models/ --include="*.sql"

# Rebuild downstream
dbt build --select <model_name>+
Error Categories
Compilation Errors
  • Check Jinja syntax: matching {{ }} and {% %}
  • Verify macro arguments
  • Check YAML indentation
Database Errors
  • Read compiled SQL in target/compiled/
  • Check column names against upstream
  • Verify data types
Test Failures
  • Read the test SQL to understand what it checks
  • Compare your model output to expected behavior
  • Check column names, data types, NULL handling
Anti-Patterns
  • Making random changes without understanding the error
  • Assuming the current model is wrong before checking upstream
  • Not reading the FULL error message
  • Declaring "fixed" without running build
  • Getting stuck making small tweaks instead of reassessing
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。