Wink Pings

No errors doesn't mean it's correct: Run AI-generated long SQL through SQLFluff first

SQLFluff can check and automatically fix SQL formatting according to dialect. But it only handles form, not business correctness. First review the lint report, then fix, then review the diff.

Once AI-generated SQL gets long, indentation, aliases, and comma placement drain your attention first. Before you've even looked at the logic, your eyes are already lost in the parentheses.

SQLFluff is an open-source SQL linting and formatting tool. It checks SQL against rules and can automatically fix many formatting issues. It supports dialects such as DuckDB, PostgreSQL, and MySQL. In practice, choose the dialect before running checks; don't force the same syntax onto different databases. Otherwise, a pile of issues in the report may simply mean you didn't select the right dialect.

It solves formatting and consistency issues; it is not responsible for judging whether query results meet business requirements. Dialect support may also not cover every syntax. A more reliable workflow is: first review the lint report, run auto-fix, then review the diff again. Don't treat 'no errors' as the query being correct. Passing syntax and being business-correct are two different things.

Link: SQLFluff. See the original recommendation in this tweet.

发布时间: 2026-11-03 21:26