logoalt Hacker News

Any text-to-SQL benchmark should address difficulties of real-world data stores

43 pointsby shenli3514yesterday at 9:54 PM13 commentsview on HN

Comments

fivetenpenyesterday at 11:13 PM

The biggest issue with business users (who don’t know SQL) writing SQL with an LLM is that there is no one to validate that query and now that business user will treat that LLM response as canon to share in meetings, presentations, and with clients. The LLM may have forgotten a filter, used the wrong definition of revenue, or misunderstood the user’s intent by writing a query that answers their question in the most literal way.

That is the crux of the issue. No amount of semantic layers and context will help this until an LLM can read the user’s mind to remove ambiguity in the prompt.

I see most of the benefits of LLMs to be used by analysts who know SQL to work more productivly.

show 1 reply
programmertoteyesterday at 10:34 PM

Interesting... at my current job, my team and I are solving this problem of how to make sure LLM understand our SQL data warehouse to answer analytical questions for clients. We have a 20-year old database with rotting schema as the blog post describes. So we had to rebuild the database in a way that is well structured and governed. Once that hard work is done, we slap dbt models on top of business metrics with model YAML files (and some common MD files) carrying a lot of semantic and metadata info for them.

Then our software engineering team ingest the dbt models (we have to tactically create dbt models; that is, always think "what would make LLM hallucinate less" as we are implementing them) and info from the semantic layer to build context for the LLM, and use that to answer analytical questions. So far, it's been promising. The accuracy isn't zero like the blog's author suggested though. We have built like 30 metrics in dbt and semantic layer in the last quarter, and asked the research and analytics teams to do internal testing on the LLM app. I will find out how accurate this approach is from the feedback soon.

show 1 reply
tqitoday at 3:44 AM

SQL generation has gotten very good, and most of the problems listed are no longer as big of a problem. addressing schema rot was always a tedious chore, but now is easily ameliorated by delegating to coding agents. Drifting definitions are solved by giving the agents access to the pipeline code.

However, in my experience the answer a business user needs is rarely the answer to the question they initially ask. Asking for clarification, pushing back on poorly framed or conceived asks where most of the value comes from. LLMs are still too eager to jump into the code, and the sycophancy problem is especially challenging in this space.

data-ottawatoday at 1:33 AM

SQL generation is quite good, 90% of the problem is data quality.

The best thing you can do for your data agent is build a clean frontroom around your specific desired use cases -- with very clear documentation and obvious idiomatic join patterns built on clear marts. It is hard work, but I've been doing this a while and this is the only way.

A full top down rebuild is rarely feasible and can take years. What I suggest is focusing on rebuilding your base layers and introducing a versioned schema/model approach (to isolate breaking changes). Even with the data/compute redundancy it introduces, it is so much easier to move the sale report from customers_v1 to customers_v2 than it is to evaluate what happens when you remove the salesforce id as primary key from customers into all the downstream dependencies.

brotchietoday at 3:23 AM

Text to SQL is the wrong framing of the problem.

Ideally you ask the agent the thing you want to know / business question you want answered.

An agentic loop then runs. The agent can look at the schema, look at any existing SQL scripts available that query similar tables, run a few limit 10 probe queries. Analyze the data, do some joins, check the data again. Show you the data, ask for feedback, etc.

Pure zero / one shot SQL generation isn’t the solution and isn’t how humans do things. We look at the schema, run some queries, do some joins, spot check the totals / row counts, etc.

overgardtoday at 12:39 AM

The problem with AI benchmarks is that they can/will be gamed. You pretty much have to keep the criteria a secret for it to mean anything. I guess that's a long winded way of saying I don't trust any benchmarks -- sql or otherwise -- because I don't think they prove much of anything.

semiquaveryesterday at 10:38 PM

  > It is widely known that an LLM can only find data it has seen before.
What does this mean? It’s obviously not literally true, so what is the author trying to convey?
mr_toadtoday at 1:07 AM

> On this benchmark, a pure LLM generated an accuracy score of zero. Adding RAG, prompt engineering, and agentic AI raised accuracy to the 10+% range.

That's awful. The AI in Databricks is much better than that.

m12kyesterday at 10:32 PM

Friend of mine built a startup around this, allowing non-techies to "query their database using natural language": https://www.blazesql.com/ Not sure how he achieved it (if TFA is to be believed), but it's my impression that his query generation and results are fairly robust.

show 1 reply