Comment by albert_e
1 day ago
Sorry for slight digression.
In a larger system we are building we need a text-to-sql capability for some structured data retrieval.
Is there a way one could utilize this library (sqlglot) to build a multi-dialect sql generator -- that is not currently solved by directly relying on a LLM that is better at code generation in general?
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:
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:
Unsure if functionality like this exists in other Query Builder libraries for other languages.
This is a SQL to X library, though. I don’t think it’s what you need.