News for hackers. Stuff that matters.
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by jmuguy on Wednesday July 12, 2023 @01:24PM (#36698211)
If you know SQL why is this better than just writing SQL? If you don’t know SQL how do you know it’s correct?

I had to forbid my coworkers from using chatgpt to generate SQL because it kept doing things slightly wrong - like missing parens when dealing with AND and OR in a where statement.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by jsight on Wednesday July 12, 2023 @01:39PM (#36698509)
I feel the same way when someone gives me an MR without suitable unit tests. How do they know it is correct?
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by getmeinrn on Wednesday July 12, 2023 @01:28PM (#36698287)
You send the produced query through a parser and a validator. The parser ensures it is syntactically correct, the validator ensures it is only accessing allowed data.
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by jmuguy on Wednesday July 12, 2023 @01:30PM (#36698321)
The SQL it produced for my coworkers ran without error - it just produced undesired results.
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by getmeinrn on Wednesday July 12, 2023 @01:38PM (#36698496)
It sounds like your concern is that an LLM is not capable of understanding an english explanation of the query and producing the correct query. I personally have not had many issues here, and the time saved by tweaking a generated query is larger than writing the query myself from scratch. And LLMs will only improve so that these tweaks require less time.
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by bugglebeetle on Wednesday July 12, 2023 @01:30PM (#36698313)
Writing tweaks to complex statements is tedious and I’m lazy? I often just feed in existing queries and scripts and say “use the below as a template, but do X,Y, and Z instead.” GPT-4 does this correctly the majority of the time and for all but a handful of circumstances, can typically be coaxed into the correct thing with a couple of back-and-forths.
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by DonaldPShimoda on Wednesday July 12, 2023 @01:51PM (#36698757)
> If you know SQL why is this better than just writing SQL? If you don’t know SQL how do you know it’s correct?

This line of reasoning applies for all areas of knowledge, and I wish more people would realize this about LLMs.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by welfare on Wednesday July 12, 2023 @01:57PM (#36698866)
I know (some) French, still use ChatGPT or Google Translate a lot to get me started if I want to send a note to someone in French. I still do some hand-waving afterwards to ensure it's correct but that's about it.

I'd argue that this process applies to any GPT-type generator, it serves a starting point so you're not staring at a blank piece of paper, but it won't give you the final result.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by jmuguy on Wednesday July 12, 2023 @02:04PM (#36698998)
The benefit of using GPT to produce something for another human is the other human can understand you even if the statement is slightly weird or incorrectly worded.

SQL doesn’t have the same tolerance.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by wodenokoto on Wednesday July 12, 2023 @02:12PM (#36699147)
Most people can read more complicated text than they can write.

Most people who need to generate a query can run it and look at the results.

I use chatgpt to help me, particularly with languages I don’t write in everyday. And I often find myself arguing with chatgpt that what it wrote is wrong, because I can read the query, but don’t know how to write the query I need.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by nonethewiser on Wednesday July 12, 2023 @02:14PM (#36699192)
I agree with your sentiment but it actually occurred to me that code might actually be the reverse - where you can write more complicated code than you can read.
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by lanstin on Wednesday July 12, 2023 @02:36PM (#36699613)
A nice corollary to Kernighan's law on debugging.

I guess it can go either way. Sometimes ChatGPT4 is great and saves me time, but the cycle of "explain what I want, get the output test/compile it, post the errors, try again" doesn't always converge quickly enough to not be more irritating than actually learning the issues in the code I'm trying to interface with. So I'll try it a bit, but if it goes back and forth more than 3 or 4 times, I'll give up and dig in to study the thing.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by nonethewiser on Wednesday July 12, 2023 @02:12PM (#36699158)
> If you know SQL why is this better than just writing SQL? If you don’t know SQL how do you know it’s correct?

You test it.

And what do you mean by “know SQL?” No one knows everything about SQL. Virtually everyone writing SQL is in between the two extreme cases you provide.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by jmuguy on Wednesday July 12, 2023 @02:19PM (#36699272)
If you understand SQL enough to know if the query ChatGPT produced is valid - you probably could have written it yourself. I don’t see how prompting chatgpt and testing its results is faster or better than just writing SQL.
Re:Ben Forta – How to Generate SQL Statements with ChatGPT by nonethewiser on Wednesday July 12, 2023 @03:05PM (#36700069)
> If you understand SQL enough to know if the query ChatGPT produced is valid

Like I said, you need to test it. Not read it. Test it.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by Mustachio on Wednesday July 12, 2023 @03:36PM (#36700461)
Imo it depends on what you're prompting. If you yourself do not fully understand what you want and/or which information you have to provide for the model to 'understand' enough context, prompts will not give good results.

I usually find ChatGPT very good for converting conceptual ideas to a concrete piece of 'boilerplate' to work off of. It can help you jump gaps in your proces, but in the end you still have to make the jumps yourself.

Re:Ben Forta – How to Generate SQL Statements with ChatGPT by d0mine on Wednesday July 12, 2023 @04:02PM (#36700856)
I can recognize much more faces than I can describe/draw. It is easier to read foreign language than to write it (active vs passive vocabulary).

It is the same with googling, looking for a solution on StackOverflow: understanding/judging whether the solution is good may be faster than constructing it yourself.