r/dataengineering • • Sep 29 '26

Discussion Why text-to-SQL is not successful?

I thought text-to-SQL will solve adhoc analysis, but still i see companies at all size are unsuccessful.

Anyone using Omni / Sigma seen some success.

27 Upvotes

89 comments sorted by

5

u/in_meme_we_trust Sep 29 '26

It seems pretty much solved to me with databricks genie agents

-1

u/de4all Sep 29 '26

With genie, we would need all metrics defined in Unity to gain more accuracy and also the cost of genie is also uncontrollable

1

u/in_meme_we_trust Sep 30 '26

Cool man. It works for me

2

u/dodovt Senior Data Engineer Sep 29 '26

My company uses omni and we properly serve self-service analytics and AI generated reports/reports with AI embedded on them.

It's our biggest LLM use-case in the company, but far from perfect. It does answer quite well the questions though as we have a very well defined metrics catalog and semantic layer.

1

u/de4all Sep 29 '26

Any learning you can share from Omni. Any particular negative stuff

2

u/geek180 Oct 01 '26

I built a pretty damn good text to sql MCP server our company is using. About half our staff are using it regularly now and it is very reliable for a wide range of questions.

1

u/de4all Oct 01 '26

What steps were considered for higher accuracy

1

u/maloik Oct 12 '26

That's pretty good adoption, congrats! What made it have good reliability? Is there some kind of shared context that you wrote to pull this off, or is it limited in what it can do so it doesn't go off the rails?

If there is context... who keeps that up to date?

27

u/leogodin217 Sep 29 '26

As u/rapator said, a semantic layer is more important than ever with LLMs, even if it is not a full-blown separate tool. Could just be views that handle the calculations. Business context is just as important. Good data modeling with good documentation should prevent the LLM from making a lot of assumptions. If you look at sessions logs and see things like, "Metric X must by tied to Table Y because...," then the business context is lacking.

4

u/gffyhgffh45655 Sep 29 '26

In a perfect world, i would argue a good semantic view,column description and metrics definition should do this heavy lifting over “gotcha information of each tables” as to me this is similar to throw a operation manual to a transactional schema to a llm and hoping it can do all the complex join required just go get something fair simple or not.

And hence what the llm ever need to do is run metrics as defined in the semantic view, to do join in a dimensional data model which is fairly easy and just to aggregate over different column that have context to tide it with business language.

TLDR (again in a perfect world) Create a model and(column) documentation such that is easy to use for data analyst and thus LLM.

Note: we do also trying this type of “table gotcha” skills for LLM as well but i still think data modelling and column documentation, choosing what column to include in your semantic view is the priority

1

u/c-phrase Oct 24 '26

What is the larger architecture that you think this should be seated within? Are you viewing this as something an agent uses, looping text-to-SQL problems. Or do you see the human user actually asking questions that, more or less, correspond to single SQL results being applied over the database?

-7

u/mamaBiskothu Sep 29 '26

I created and maintain a product that has 8 figure revenue solving this exact use case. Your interpretation and how many people keep calling it "text to sql" is precisely the type of buzzword laden bs thinking that makes these agents fail. F semantic layers, ontologies, graphs, rag and any of these stupid things.

Connect claude code to your sql engine, tell it the names of the tables that you care about (or honestly, dont) and just ask the real question you care about. Dont try to smartass any harness on top of these models. Most people arent smart enough not to get in the way of the agents than help.

5

u/leogodin217 Sep 29 '26

How do agents know the definition of your metrics without documentation? We all know total sales is never as simple as sum(sales). This sounds like a way to be in meetings where there people have different numbers for the same metric names.

-2

u/mamaBiskothu Sep 29 '26

Have you tried the latest models? The models know total sales is not sum of sales. point claude code to the data ask that questuon and then comment.

1

u/leogodin217 Sep 29 '26

I have, and they will never know that Marketing excludes x and y and sales includes z and x from other tables. I've been part of that discussion more times than I can count across many domains. Even when I worked in IT instead of BI and data engineering.

I'm more curious about your product. I re-read your comment and I can't figure out if you're saying your product isn't needed or if I just missed something.

20

u/SpookyScaryFrouze Lead Data Engineer Sep 29 '26

It works, you just need to document your tables, columns and kpis perfectly.

3

u/Equivalent_Lunch_944 Sep 29 '26

But let’s be honest that’s often not the case, and if it were being able to query with text instead of SQL is much less valuable

1

u/SpookyScaryFrouze Lead Data Engineer Sep 29 '26

How would you query using text instead of SQL ? Even if you ask your question in natural language, it still has to be translated to SQL in order to retrieve your answer. So you still need to have an up-to-date documentation on your data, which is otherwise known as a semantic layer.

1

u/EstetLinus Oct 01 '26

+1. At my company, metric correctness is decided by how widely used a particular definition is. That makes it hard to do anything ”perfectly” (and I know that this is how it looks like at a majority of organizations).

A semantic model is very good, but we usually fall short with weird edge cases. Most effort is still in designing data models.

8

u/hadoopfromscratch Sep 29 '26

Text-to-sql does work. We are using Databricks (Genie spaces). And its quite reliable

8

u/ludflu Sep 29 '26

because if you don't have enough domain knowledge to formulate a query then you also don't have enough domain knowledge to understand the results. (for anything more complicated that selecting from a single table, IMO)

6

u/ppsaoda Sep 29 '26

On data side, it's semantics and metadata. On platform side, AI tooling and harnesses.

3

u/BrownBearPDX Data Engineer Sep 29 '26

Describe in meta every table and every field with join hints even if there aren’t hard fks.

1

u/Equivalent_Lunch_944 Sep 29 '26

Remember when power bi had that thing where it turned text to visualizations that they were touting was the future.

1

u/de4all Sep 29 '26

Thats true and now I assume MS will gut PBI. They want everything to merge with Fabric

1

u/Equivalent_Lunch_944 Sep 29 '26

Maybe. IMO a lot of the discourse around AI and these solutions is like health advice; we all roughly now what to do to be healthy; eat better and exercise. It’s the doing it and sticking with it that’s hard.

I don’t know how different the ‘solution’ to storing and retreiving data has changed. It’s still about smart and predictable Db design but it’s always been that way. So I’m not so what AI changes in that. But I’m a skeptic though so maybe I’m missing something.

1

u/morpho4444 Señor Data Engineer Oct 06 '26

What is wrong with this subreddit, AI is not replacing and is not as good... IN YOUR LITTLE BUBBLE... everywhere else who knows how to do this, we all know AI is doing most if not all of the coding and even pushing the PR directly into main branches including handling not only adhoc reporting, in my company, we created adhoc etl, final users can go and create their own metrics, tables and full pipelines just using chat.

1

u/de4all Oct 06 '26

The question is HOW part? And not AI replacing Data teams.

1

u/morpho4444 Señor Data Engineer Oct 06 '26

Yes I know, I added that. This subreddit is full of criticism of AI. I work for Big Tech. Adhoc text to sql is solved.

3

u/dehaenx Sep 29 '26

When you don't have a semantic layer and have scattered definitions and metrics, you'll see the LLM retrieving several answers from a seemingly "simple" definition. For instance, if you have "net sales" as a term, finance, sales, CSM could all define it slightly differently, and because the LLM is just parsing through your raw data, it will return multiple results. It's best to invest in a program that could develop, and more importantly, maintain your semantic layer and keep your definitions and metrics up to date and in check all the time. Save yourself a headache and some money lol

3

u/Acceptable-Milk-314 Sep 30 '26

Never talked with a corporate executive have you?

3

u/pubic_discourse Oct 01 '26

My take is that there need to be higher order semantic concepts, e.g. what does “big” mean - how do I pin fuzzy or qualitative adjectives? People think sets of entities and language itself is in an SVO (subject verb object) structure. All these “semantic layers” have nothing semantic about them. They’re really more of a paragraph about your table, and a row can be any abstruse unit.
I once heard it said “the problem in analytics is the best way to store your data has nothing to do with the best way to read and interpret your data”
Id love to see a solution which paradigmatically addresses that

2

u/query-gremlin Sep 29 '26

The problem often lays with the data model underneath. Incomplete or unclear data dictionaries, or lack of semantic description of the data model would make the LLM blindly guess at best.

2

u/Atticus_Taintwater Sep 29 '26

Because writing SQL was never the hard part

Crisp easy SQL is a byproduct of everything else that's hard done right.

1

u/c-phrase Oct 24 '26

I have a fair bit of experience with this problem. And in fact I gave a lecture in my course about this exact area: https://youtu.be/clRu2a6NjS4

I think we need to consider several different use cases.

  1. An MCP server that supports Text-to-SQL over a specific database. In this case the agent can loop around looking for the proper way to access the underlying database. It may try and fail in a loop exploring the access paths and piecing together a larger, response built from multiple queries. This fits in well with dialogue and is surprisingly effective.
  2. A coding agent can build text-to-SQL snippets that it places in deterministic code that can be touched up/verified by a developer in the resulting applications.
  3. The old fashioned, but purer problem of letting people generate SQL that gets pasted into a terminal/executed through library calls like db2.,0 API/ODBC. This is the hardest path to get useful results out of. But it confronts the direct problem in an unobscured way. So it is worth considering.

There are a lot of questions around hallucinations/idiosyncrasies. Stonebreaker does not think AI will solve the problem because of idiosyncracies. Lots of issues about six sigma with this stuff especially with write queries.

I am looking at the old idea of semantic tractability to try to give reliable MCP servers: https://c-phrase.com
It will be interesting to see how this topic evolves in the coming years.

1

u/Hour-Measurement-835 Sep 29 '26

No idea on Omni or Sigma. NetSuite's mainline rows alone would trip up a naive SUM(amount).

1

u/zangler Sep 29 '26

I'm not sure what you were using, but I have a semantic layer and good documentation, and ad hoc is phenomenal using Copilot CLI and the MSSQL MCP...like... easily over 98% 1 shots even complicated requests.

1

u/BaguetteBrot Sep 29 '26

I'm currently in a project trying to that with Snowflake Cowork and their semantic layer concept. Right now we are in the midst of preparing the data model with clean dimensional modeling (Kimball) and clear column and table descriptions. I'm excited to see how this will all turn out.

We are also looking for a new visual layer with Omni, Sigma or Hex. But we are not there yet. Anyone has prices from those 3? Just curious and we haven't asked for a quote directly yet.

1

u/FuzzyCraft68 Data Engineer Sep 29 '26

Are you my manager? This feels like my manager asking the question because he wants to feed people AI slop to corporate saying it is self serving report.

Here is why it is failing, it doesn't know business context. That's it! Some stuff from source system are modelled in a certain way that it is not easily replicable with 1 prompt, there is lot of understanding which goes through while creating facts and dims.

1

u/[deleted] Sep 29 '26 edited Oct 21 '26

The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.

Nose air hydrogen gaze edge depend slap flag tangerine jeans

1

u/Creative_Salary_6140 Sep 30 '26

Requires understanding the data model and business domain knowledge, even the latest AI models I’ve used aren’t getting it right.

1

u/DMReader Sep 30 '26

I’m trying to implement this right now I’ve got done limited success so far.

1

u/Hobob_ Sep 30 '26

People still refuse to use vlookup...

1

u/Much_Discussion1490 Sep 30 '26

Because SQL isnt hard for 90% of the queries that non tech stakeholders need to run. Which is who text-to-SQL is intended for. At max knowledge upto aggregation functions is more than enough. Knowledge until partitions pretty much covers all that is necessary for most users unless you are a data engineer.

What matters more is the domain knowledge which helps you evaluate which tables are worth querying and also how the data is structured in particular column. A simple currency column which has been mislabeled from the beginning to hold local currency values across countries will give you the wrong results even if yku execute everything in the query correctly.

SQL isnt a bottleneck unless you are absolutely technically blind. Its like the excel of 2000s . You jjst need to be well aware of the basics if you are even one hop away from data. Domain knowledge is the real bottle neck

1

u/BobDope Sep 30 '26

SQL is intergalactic data speak. A natural and clean way to interact with and think about data and learning it is not exactly a huge lift. Any other approach is going to have friction and slippage/leakage. People will never learn perhaps.

1

u/innerthai Sep 30 '26

There are two reasons text-to-SQL fails:

  • Schema rot + no semantic layer
  • Weak AI model

The solution for schema rot (i.e., column names don't reflect its purpose, tables that are no longer used, etc.) is semantic layer. See https://reportr.com/ for a tool that has semantic layer.

If you use a weaker model such as one of the "open weight" models then that's when SQL generation will not be good. If your data is highly confidential then using a self-hosted open-weight model is not the answer, instead use Claude or OpenAI on AWS Bedrock ( https://aws.amazon.com/bedrock/ ), it guarantees data confidentiality.

1

u/Careful-Round-5560 Oct 01 '26

One of my friends works on it he was the one who set it up in their company and he said it really made life easier for users there. The key was to setup a semantic layer with proper details.

1

u/kvlonge Oct 01 '26

Uhh, with modern day cli agents, they are already doing a pretty stunning job. I am not sure what tools you are using, but claude code, opencode etc... if hooked up to your warehouse (can just be a python skill) do plenty more than alright.

1

u/Mr_Nickster_ Oct 05 '26

It is very successful if implemented using Enterprise Grade AI servicea vs DIY and OSS. Text2SQl requires context to be accurate which is delivered at least in Snowflake via semantic views. Semantic views provide the agents the necessary context, rules and guardrails to generate highly accurate SQL statements and to make sure the execute properly.

Context including data model, joins, lineage, synonyms, sample values, metrics. Facts and dimensions, vectorized dim values for high cardinality dims for accurate filtering with misspelled values, on going automated updates based on current usage patterns against the tables in these models by other tools, users and services.

Building the proper context is the hardwork, generating SQL is secondary.

It is pretty common to have 92% or higher accuracy with Snowflake AI agents with auto generated semantic views when it comes to business user facing AI agents.

1

u/jemattie Oct 05 '26

Text2SQL is actually easy to do once you figure out to not let the model write SQL. Let it use a more restrictive API to your data. Something akin to what CubeJS and dbt Metricflow do.

Effective use of AI in corporations requires restricting the degrees of freedom it has. Freedom constrains, constraints liberate.

1

u/TacticalBunchies Oct 06 '26

Works fine on my agent. 

1

u/BackgroundAlert Oct 06 '26

i've tested several well known tools marketed itself as semantic layer (cube, metricflow, databricks metric view, snowflake metric, holistics) against claude code + ERD + business context written in plaintext. capability wise, i dont see semantic layer could beat text-to-sql. modern LLMs are pretty good at writing SQL, and the business context helps direct its vector in writing it correclty.

but i think this would not practical in companies. since maintaining those markdown could become nightmare once it grows its size.

one important problem is validation bottleneck. i can validate the SQL claude wrote if everyone is waiting for me to answer. however if the whole company has claude + database connection, it would really hard to control correctness. people could consume plausible but wrong numbers without even knowing.

so i'm really afraid if semantic layers are solving the right problem.

1

u/maloik Oct 12 '26

The validation bottleneck is really the same bottleneck as it is with "oldschool" BI solutions in that it requires someone with the technical know-how (for both the tool and the data) to babysit everything. Plausible but wrong data ending up in some kind of slide deck is pretty much a given

A better SQL writer is effort going to the wrong place really. The real value is in making sure the definitions are something that get reviewed and maintained instead of re-derived in every chat. Your markdown files do that but it's tricky to scale I'm assuming. It's also not structured data which means it's kind of hard to reliably find out what's missing or wrong if the schema does end up changing

I'm curious about what put you off of those semantic layer solutions though. Is it the upfront effort in modeling everything? Are they too limited compared what people tried to ask?

1

u/Odd-Government8896 Sep 29 '26

What are you talking about? People are using this for self service analytics all over the place. I wont even mention the companies because I want you to know youre misinformed or behind, not which company is doing it.

0

u/Personal_Ad1143 Sep 29 '26

OP is a time traveler from early 2023

0

u/TheRealStepBot Sep 29 '26

It just works though. Straight up skill issue.

-2

u/mamaBiskothu Sep 29 '26

Every single person mentioning a semantic layer is a moron. As many mention, DB Genie and snowflake coco finally started working because they also stopped trying to make semantic layers work. Agents work best when you let them discover things themselves. The semantic layer is worse in our evals than just letting the agents discover tables using information schema queries.

Stop trying to semantic layers happen. They are never gonna happen.

1

u/Prestigious_Bench_96 Sep 30 '26

It IS surprisingly hard to get semantic layers to win in token cost vs information schema for a typical agentic loop (you need a pretty big warehouse/complexity). A well documented information schema is arguably your first and cheapest semantic layer - if you then start to duplicate column definitions across tables, want to keep them in sync, want common join paths, etc that's when you'd maybe want more?

If you have evals, you're halfway there - a "semantic layer" is just going to be a cached set of discovery in your warehouse that can be reused and iterated on to reduce variability/E2E execution cost. Some of them also have query simplification/guardrails. For sufficiently large warehouses and/or query bills, they'll come out ahead on evals - but 75% of the benefit is just getting the evals and the warehouse documented.

0

u/[deleted] Sep 29 '26

[deleted] — view deleted comment

-6

u/de4all Sep 29 '26

Any suggestions for tool to use for Semantic layer. We use dbt for modeling

22

u/saif3r Sep 29 '26

dbt has semantic layer for their platform offering

13

u/Fast-Dealer-8383 Sep 29 '26

Databricks. The Databricks' Unity Catalog and Genie Ontology tools are meant to serve as the semantic layer to power their in-house Genie AI tool as an integrated suite.

9

u/JohnPaulDavyJones Sep 29 '26

Have y'all found Genie AI To be functional?

Our data warehousing is fairly sizable for a F300 firm, but I still thought Genie would be more functional than we've found it to be. Very disappointing.

4

u/kenncann Sep 29 '26

It barely writes valid sql for me in their own language 😂 keep hoping one day it gets better

2

u/Latter-Corner8977 Sep 29 '26

Genie is shite. 

1

u/BRSF Sep 29 '26

I used genie to set the retentiondays of all tables in a particular schema to 60 days

1

u/Fast-Dealer-8383 Sep 30 '26

Can I assume that y'all had set up your unity catalog properly, with the proper labelling and configuration of data elements, metric views and functions? My organisation is in the early stages of evaluating it for implementation.

1

u/JohnPaulDavyJones Sep 30 '26

I hope so, we had consultants in from DBX to help us get set up for that first year. They cost a pretty penny, and seemed like they had the process down pat.

2

u/mrg0ne Oct 02 '26

Snowflake also has semantic modeling and you can bootstrap with CoCo.

The industry is thankfully coalescing around Apache Ossie, which is a vendor neutral spec for something modeling.

-2

u/Warm-Blueberry-2114 Sep 29 '26 edited Sep 30 '26

Agreed, though I'd split it in two. A semantic layer fixes what a metric means. It says nothing about whether the rows are sound. You can compile perfectly correct SQL against a table where one customer is four rows and 8% of a column is null, and get back a confident, well-defined, wrong number. Most shops I've seen are strict about one and silent about the other, and then blame the model when the answer doesn't survive a second look.

5

u/Prestigious_Bench_96 Sep 30 '26

A reasonable semantic layer should include testable assertions about the data that you can validate regularly. (but yeah, not everyone does that).

But the semantic layer is useful as a contract on both sides.

1

u/nemec Sep 30 '26

ok claudegpt

1

u/[deleted] Sep 29 '26

[removed] — view removed comment

1

u/dataengineering-ModTeam Sep 29 '26

Your post/comment was removed because it violated rule #9 (No AI generated content/text).

Your post/comment was reviewed to be AI generated/assisted content/text and removed as a result. We as a community value human engagement and encourage users to express themselves authentically.

This was reviewed by a human

1

u/[deleted] Sep 30 '26

[removed] — view removed comment

1

u/dataengineering-ModTeam Oct 01 '26

Your post/comment was removed because it violated rule #9 (No AI generated content/text).

Your post/comment was reviewed to be AI generated/assisted content/text and removed as a result. We as a community value human engagement and encourage users to express themselves authentically.

This was reviewed by a human

1

u/[deleted] Sep 30 '26

[removed] — view removed comment

1

u/dataengineering-ModTeam Oct 01 '26

Your post/comment was removed because it violated rule #9 (No AI generated content/text).

Your post/comment was reviewed to be AI generated/assisted content/text and removed as a result. We as a community value human engagement and encourage users to express themselves authentically.

This was reviewed by a human

1

u/[deleted] Oct 07 '26

[removed] — view removed comment

1

u/dataengineering-ModTeam Oct 15 '26

Your post/comment was removed because it violated rule #5 (No shill/opaque marketing).

Any relationship to products or projects you are directly linked to must be clearly disclosed within the post.

A reminder to all vendors and developers that self promotion is limited to once per month for your given project or product. Additional posts which are transparently, or opaquely, marketing an entity will be removed.

This was reviewed by a human

0

u/[deleted] Oct 14 '26

[deleted] — view deleted comment

1

u/dataengineering-ModTeam Oct 17 '26

Your post/comment was removed because it violated rule #9 (No AI generated content/text).

Your post/comment was reviewed to be AI generated/assisted content/text and removed as a result. We as a community value human engagement and encourage users to express themselves authentically.

This was reviewed by a human