Lint and Cleanup
SQL Query Formatting Review Guide
Review formatted SQL by checking readability, data scope, execution risk and safe examples instead of only whitespace style. This reference is written for developers who need practical validation behavior, reviewable rules and safe examples rather than copied snippets with no explanation.
Recommended workflow
| Step | Why it matters |
|---|---|
| Read the query top down | A reviewer should understand selected fields before digging into filters. |
| Verify data ownership | Team, tenant, account and permission filters deserve explicit attention. |
| Check aggregation | GROUP BY mistakes often look like formatting changes until totals are wrong. |
| Keep a rollback note | Production SQL changes need an easy way back. |
Starter snippet
Review order: selected columns -> joins -> filters -> grouping -> ordering -> limitsReview checks
- Confirm aliases match business meaning.
- Check ORDER BY and LIMIT when pagination is involved.
- Run read-only verification queries for changed reports.
- Redact real IDs before asking for help.
Common mistakes
- Approving a formatted query because it looks neat.
- Forgetting tenant or team scope during cleanup.
- Comparing only one example row after a rewrite.
Validation should help users correct input while protecting systems from bad data. Keep syntax checks, product policy, security review and deliverability checks separate.
Related Formalint references
Continue with SQL Cleanup Checklist, Sql Group By Debugging Guide, Database Incident Forum.