r/dataengineering • u/de4all • 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
5
u/in_meme_we_trust Sep 29 '26
It seems pretty much solved to me with databricks genie agents
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.
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.
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.
20
u/SpookyScaryFrouze Lead Data Engineer Sep 29 '26
It works, you just need to document your tables, columns and kpis perfectly.
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.
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/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.
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.
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/Fresh-Secretary6815 Sep 29 '26
semantic kernel https://learn.microsoft.com/en-us/semantic-kernel/overview/
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:
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/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/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.
0
u/[deleted] Sep 29 '26
[deleted] — view deleted comment
1
u/[deleted] Sep 29 '26
[removed] — view removed comment
1
u/[deleted] Sep 30 '26
[removed] — view removed comment
1
u/[deleted] Sep 30 '26
[removed] — view removed comment
1
u/[deleted] Oct 07 '26
[removed] — view removed comment
0
u/[deleted] Oct 14 '26
[deleted] — view deleted comment