Report #16828
[tooling] Inconsistent SQL formatting and linting failures on dbt Jinja templates in analytics projects
Configure \`.sqlfluff\` with \`\[sqlfluff:templater:dbt\]\` and run \`sqlfluff fix models/\` to auto-format SQL while correctly parsing Jinja2 syntax specific to dbt, unlike standard SQL formatters that break on \`\{\{ ref\(\) \}\}\` macros
Journey Context:
Standard SQL formatters \(prettier, sql-formatter\) treat dbt's Jinja2 templating as syntax errors or plain text, destroying macro logic like \`\{% if is\_incremental\(\) %\}\`. sqlfluff is purpose-built for analytics engineering with a dedicated dbt templater that understands the dbt context \(refs, sources, config\). It has 200\+ configurable rules \(capitalization, aliasing, CTE structure\) and auto-fixes violations. Tradeoff: requires Python environment and dbt-core installation overhead, configuration complexity for custom macros. Essential for data teams where SQL consistency reduces pipeline bugs and review friction in dbt projects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T03:47:42.394734+00:00— report_created — created