←back to thread

Getting AI to write good SQL

(cloud.google.com)
478 points richards | 4 comments | | HN request time: 0.602s | source
Show context
rectang ◴[] No.44010899[source]
> We will cover state-of-the-art [...] how we approach techniques that allows the system to offer virtually certified correct answers.

I don't need AI to generate perfect SQL, because I am never going to trust the output enough to copy/paste it — the risk of subtle semantic errors is too high, even if the code validates.

Instead, I find it helpful for AI to suggest approaches — after which I will manually craft the SQL, starting from scratch.

replies(4): >>44011204 #>>44011349 #>>44011379 #>>44011432 #
1. hosel ◴[] No.44011204[source]
Really? In my experience it’s been pretty good (using Pydantic)! I read over before I execute it, but it’s never done anything malicious.
replies(3): >>44011259 #>>44011340 #>>44013480 #
2. rectang ◴[] No.44011259[source]
I don't trust myself to craft a prompt in natural language which completely specifies my intent as codified with the precision of a programming language.

I also tend to turn to AI for advising me on difficult use cases, and most of the time it's for production code rather than one-offs. The easy cases, I just write myself because it's more mental effort to review code for subtle errors than it is to write it.

3. ◴[] No.44011340[source]
4. yahoozoo ◴[] No.44013480[source]
What is the relevance of Pydantic with SQL?