AI SQL Generation: Overcoming Dialect-Specific Syntax

3 gavinray 1 5/17/2025, 2:27:26 PM gavinray97.github.io ↗

Comments (1)

gavinray · 9h ago
In response to the recent Google Cloud post "Getting AI to write good SQL" [0] and some comments I've seen here lately [1], I wanted to share an approach that I've found useful for portable, dialect-agnostic SQL generation.

tl;dr = Use an abstract Query IR/AST as your generation target, rather than embedding dialect-specific syntax rules. Then render the IR to a target dialect programmatically.

Hopefully this is useful for other folks working in the "need to support multiple SQL dialects for my product" space.

- [0] https://news.ycombinator.com/item?id=44009848

- [1] https://news.ycombinator.com/item?id=43812675