John Liu Blog

Every drop counts

SQL Formatter

To format SQL query to your specific style, we can utilise combination of SQLFluff and Python code without built a SSM extension. How the single-step pipeline works Step 1 (SQLFluff Python API): Formats your .sql file deterministically (casing, leading commas, ON breaks, CASE blocks) Step 2 (AST Join-Tree Indenter via sqlglot): Parses the FROM clause, checks which table alias each JOIN … ON references (e.g., LC references L, B references LC), and automatically indents that entire JOIN + ON block one tab deeper under its parent table.