Comment by gavinray
1 day ago
You can use an LLM to generate query-builder expressions from popular libraries in whatever language.
For example, on the JVM there is jOOQ, which allows you to write something like:
select(field("foo"), avg("bar")).from(table("todos"))
And then it will render dialect-specific SQL. It has very advanced emulation functionality for things like JSON aggregations and working around quirks of dialects.
Alternatively, you can ask an LLM to generate a specific dialect of SQL, and then use jOOQ to parse it to an AST, and then render it as a different dialect, like:
val parser= DSL.using(SQLDialect.POSTGRES).parser()
val parsedQuery = parser.parseQuery(postgresQuery)
val renderedMySQL = DSL.using(SQLDialect.MYSQL).renderInlined(parsedQuery)
println(renderedMySQL)
Unsure if functionality like this exists in other Query Builder libraries for other languages.
No comments yet
Contribute on Hacker News ↗