Jump to Section (07)
- 01 / Why do enterprise text-to-SQL demos collapse on live company databases?
- 02 / Why do bloated enterprise schemas blind AI before the first join?
- 03 / How do unanswerable questions turn into silent, executable wrong numbers?
- 04 / Why does naive agentic looping waste tokens and still miss constraints?
- 05 / What four architectural gates keep enterprise text-to-SQL accurate?
- 06 / Frequently Asked Questions
- 07 / Primary Sources (08)
- Academic SQL demos hide an enterprise accuracy cliff: Spider 2.0 tests 632 real workflows on warehouses often exceeding 1,000 columns in systems like BigQuery and Snowflake [2]. An o1-preview code agent solves only 21.3% there, compared with 91.2% on academic Spider 1.0 and 73.0% on BIRD [2].
- Private company warehouses stall frontier agents even with hints: BEAVER compiles 9,128 real warehouse query-log pairs across 812 tables and 19 domains [3]. GPT-5.2 agentic frameworks score only 10.8% accuracy and reach just 30.1% even when given human hints for all 5 critical subtasks [3].
- Unanswerable prompts can run quietly and fabricate numbers: Unanswerable and underspecified text-to-SQL questions may generate executable programs that yield misleading results or violate safety constraints [5]. Prompt-only refusal stays brittle under hallucinations [5].
- Compression and refusal gates stop bad joins early: On Spider 2.0-Snow and BIRD, database-side compression (DBCC) shrinks the largest Spider 2.0-Snow subset from 2.6M to 34.7K tokens and lifts finding every required database element (schema-linking strict recall) from 0% to 56.5% (DeepSeek-V3.2) and 63.1% (Claude Opus 4.7) [6]. LatentRefusal flags unanswerable SQL across 4 benchmarks at 88.5% (Llama-3.1-8B) and 88.8% (Qwen-3-8B) average F1 (balancing catches against false blocks) while adding ~2ms probe overhead [5].
- Row probing, rule checklists, and trace memory improve accuracy and cost: PV-SQL beats the best BIRD baseline by 5% in correct SQL results (execution accuracy) and 20.8% in valid efficiency score (correct queries that run efficiently on large databases) with fewer tokens [7]. AgentSM cuts Spider 2.0 average tokens 25% and reaches 44.8% correct-query accuracy on Spider 2.0 Lite [8].
- 91.2% to 21.3% drop from public to enterprise SQL: An o1-preview code agent drops from 91.2% on academic Spider 1.0 and 73.0% on BIRD to 21.3% on Spider 2.0's 632 enterprise tasks [2]. In BIRD, ChatGPT achieved 40.08% correct SQL results (execution accuracy) vs. 92.96% for humans [1].
- 10.8% accuracy on private enterprise warehouses: Across BEAVER's 9,128 private queries and 812 tables, GPT-5.2 agentic frameworks score 10.8% [3]. Supplying human hints for all 5 critical subtasks raises accuracy to only 30.1% [3].
- 2.6M to 34.7K token compression rescues table matching: Database-side compression (DBCC) shrinks the largest Spider 2.0-Snow subset up to two orders of magnitude [6]. Finding every required database element (schema-linking strict recall) climbs from 0% to 56.5% (DeepSeek-V3.2) and 63.1% (Claude Opus 4.7), adding 1.8 to 1.9% execution accuracy over 3 systems on Spider 2.0-Snow and BIRD [6].
- Refusal, probing, checklists, and memory raise reliability: LatentRefusal hits 88.5% (Llama-3.1-8B) and 88.8% (Qwen-3-8B) average F1 (balancing catches against false blocks) across 4 benchmarks at ~2ms added probe overhead [5]. PV-SQL beats the best BIRD baseline by 5% in correct SQL results and 20.8% in valid efficiency score (correct SQL that runs efficiently) with fewer tokens [7]. AgentSM cuts Spider 2.0 average tokens 25% and shortens reasoning paths (trajectory length) 35%, reaching 44.8% correct-query accuracy on Spider 2.0 Lite [8].
Why do enterprise text-to-SQL demos collapse on live company databases?
Every BI vendor runs the same magic trick for executives. Type a plain-English revenue question into a chat box, watch SQL appear in seconds, and admire a clean chart. Leaders immediately picture self-service finance without waiting days for an analyst.
Then the pilot connects to the real company warehouse.
Tables carry cryptic legacy codes, audit timestamps repeat across dozens of views, and business definitions sit inside scattered docs. Worse, the generated SQL rarely throws a red syntax error. It runs cleanly, prints a confident dollar total, and silently joins the wrong table or omits a key filter.
Primary benchmarks trace this exact cliff from clean academic databases to real enterprise warehouses.
Prevalent early benchmarks like Spider and WikiSQL focused on tidy schemas with few rows of database contents, masking real operational friction [1]. Researchers built BIRD with 12,751 question-SQL pairs across 95 databases totaling 33.4 GB and 37 professional domains [1]. BIRD exposed dirty database values, external domain knowledge linking business terms to stored values, and SQL efficiency limits [1]. In that NeurIPS study, ChatGPT reached only 40.08% execution accuracy (correct SQL results), far behind the 92.96% human result [1].
Newer models improved on BIRD, yet enterprise workflows still broke them. Spider 2.0 compiled 632 real enterprise text-to-SQL workflow problems from live data applications [2]. Those databases often contain over 1,000 columns in local or cloud systems such as BigQuery and Snowflake [2]. Answering one request frequently requires searching metadata, dialect documentation, and project codebases while generating multiple SQL queries exceeding 100 lines [2].
Under those real conditions, an o1-preview code agent solved only 21.3% of Spider 2.0 tasks, compared with 91.2% on Spider 1.0 and 73.0% on BIRD [2].
Private corporate warehouses reveal an even steeper cliff. Researchers built BEAVER directly from private enterprise query logs, covering 9,128 question-SQL pairs and 812 tables across 19 domains [3]. On BEAVER, state-of-the-art agentic frameworks using GPT-5.2 achieved only 10.8% accuracy [3]. Even when given human hints for all 5 critical subtasks, accuracy rose to just 30.1% [3].
| Primary Study | Evaluation Scope | Verified Finding | Operational Takeaway |
|---|---|---|---|
| BIRD [1] | 12,751 pairs, 95 databases (33.4 GB, 37 domains) | ChatGPT hits 40.08% execution accuracy (correct SQL results) vs. 92.96% human result | Clean toy schemas hide value-format and domain-rule errors |
| Spider 2.0 [2] | 632 real workflows (often > 1,000 columns, BigQuery/Snowflake) | o1-preview agent solves 21.3% vs. 91.2% on Spider 1.0 and 73.0% on BIRD | Multi-query warehouse analytics fail far more than public demos |
| BEAVER [3] | 9,128 private log pairs, 812 tables, 19 domains | GPT-5.2 agents score 10.8%, rising to only 30.1% with human hints for all 5 subtasks | Intricate private schemas and advanced functions stall frontier agents |
| RTS [4] | Statistical schema checks that abstain or ask humans on BIRD | Near-perfect table and column matching (schema linking) lets a small SQL model almost match much larger models | Escalating uncertain schema links beats silent guessing |
| LatentRefusal [5] | Unanswerable SQL gating across 4 benchmarks | 88.5% (Llama-3.1-8B) and 88.8% (Qwen-3-8B) average refusal F1 (balancing catches vs. false blocks) at ~2ms probe overhead | Gate unanswerable prompts before SQL runs |
| DBCC [6] | Large warehouse schemas on Spider 2.0-Snow and BIRD | Cuts largest subset 2.6M to 34.7K tokens, lifts strict recall 0% to 56.5% (DeepSeek-V3.2) / 63.1% (Claude Opus 4.7), adds 1.8 to 1.9% execution accuracy over 3 systems | Compress schema clutter before any model reads the catalog |
| PV-SQL [7] | Live row probing + rule-based checklist on BIRD | Beats best baseline by 5% correct SQL results and 20.8% valid efficiency score (efficient valid SQL) with fewer tokens | Probe live rows and check constraints before delivery |
| AgentSM [8] | Structured semantic memory on Spider 2.0 | Cuts average tokens 25% and reasoning paths (trajectory length) 35%, reaches 44.8% execution accuracy on Spider 2.0 Lite | Reuse prior or curated traces as structured programs |
A vendor chatbot scoring 91.2% on Spider 1.0 [2] looks ready during procurement. Connected to 812 private tables [3] or cloud warehouses often exceeding 1,000 columns [2], the same stack fails most real requests. This matches the breakdown in why AI document and spreadsheet extraction breaks at scale.
Why do bloated enterprise schemas blind AI before the first join?
Ask any data leader why analysts need months to learn an ERP warehouse. SQL syntax is rarely the hurdle. Knowing which of dozens of near-duplicate order tables holds recognized revenue takes real work.
AI query generators hit that wall instantly.
Real enterprise databases accumulate repeated audit columns, large groups of similar tables, opaque identifiers defined only inside documentation, and sprawling data dictionaries [6]. Query-aware schema linking (identifying the key database elements a query needs [4]) and retrieval-based selection try to filter this catalog, yet they still operate over redundant, verbose text [6].
On the largest Spider 2.0-Snow subset, raw input context reached 2.6M tokens [6]. Under raw schemas, schema-linking strict recall sat at 0% for DeepSeek-V3.2 and Claude Opus 4.7 [6]. Once step one misses a required table or column, downstream joins fabricate numbers.
BEAVER confirmed that intricate private schemas, domain knowledge, and analytical queries create a steep bottleneck [3]. Even with human hints for all 5 critical subtasks, GPT-5.2 agents topped out at 30.1%, with residual errors persisting around advanced functions [3]. Swapping in a pricier model cannot rescue an undocumented catalog dumped into a prompt.
How do unanswerable questions turn into silent, executable wrong numbers?
In a standard text chatbot, an uncertain answer reads vaguely enough for a sharp manager to question it. In enterprise text-to-SQL, uncertainty emits valid executable code.
Picture a VP of Sales asking for net churn by enterprise tier when the warehouse logs gross cancellations without a tier field. A helpful SQL assistant rarely stops to admit a column is missing. It grabs a nearby status code, runs clean SQL, and prints a confident percentage.
LatentRefusal researchers warned that unanswerable and underspecified queries may generate executable programs that yield misleading results or violate safety constraints [5]. Prompt-only refusal fails because output-level instruction following stays brittle due to model hallucinations, while uncertainty estimation adds complexity and overhead [5].
ACM database researchers behind Reliable Text-to-SQL (RTS) likewise found that current systems often generate unreliable outputs under ambiguity or insufficient context [4]. Safe interfaces must detect potential schema-linking errors early and abstain or ask the user to clarify before running SQL [4]. This mirrors the silent guessing in why enterprise RAG chatbots guess without escalating.
Why does naive agentic looping waste tokens and still miss constraints?
When one-shot SQL fails, vendors wrap the model in an autonomous retry loop. Catch syntax errors and retry until the database returns rows.
On real warehouses, blind retry loops fail in two quiet ways.
First, zero database errors never proves business accuracy. A query that drops a status filter, currency rule, or date cutoff still runs cleanly. PV-SQL researchers noted that text-to-SQL systems often struggle with deep contextual understanding on complex queries with subtle requirements, leaving missing constraints [7].
Second, naive agents burn budget repeating exploration mistakes. AgentSM researchers documented that agentic text-to-SQL systems suffer from inefficiency and instability, repeating database calls, producing inconsistent outputs, and occasionally failing to return valid answers [8]. Relying on raw scratchpads or vector retrieval forces the agent to rediscover paths from scratch [8]. The same audit gap breaks totals in why invoice OCR processing fails line-item audit checks.
What four architectural gates keep enterprise text-to-SQL accurate?
Reliable enterprise analytics treats SQL generation as a gated verification pipeline. Four research-backed controls address schema bloat, silent unanswerable execution, missing business constraints, and unstable agent loops:
- Compress raw database context before any LLM reads it: Keep repeated audit columns and bloated data dictionaries out of raw prompts [6]. DBCC works as model-agnostic database-side middleware combining offline structural and semantic compression with lightweight online evidence purification [6]. On Spider 2.0-Snow and BIRD, it cut context up to two orders of magnitude (from 2.6M down to 34.7K tokens on the largest Spider 2.0-Snow subset), lifted strict schema-linking recall from 0% to 56.5% (DeepSeek-V3.2) and 63.1% (Claude Opus 4.7), and raised execution accuracy 1.8 to 1.9% over 3 recent systems [6].
- Gate unanswerable and ambiguous queries before SQL runs: Drop brittle prompt-only refusal rules [5]. On open-weight deployments where hidden layers are accessible, two pre-execution gates work together. LatentRefusal probes intermediate hidden activations to amplify question-schema mismatch cues, reaching 88.5% (Llama-3.1-8B) and 88.8% (Qwen-3-8B) average F1 across 4 benchmarks while adding ~2ms probe overhead [5]. For ambiguous schema linking, RTS uses statistical conformal checks on hidden layers to abstain or involve a human [4]. On BIRD, RTS reached near-perfect schema linking, letting a small SQL model almost match state-of-the-art accuracy from a model orders of magnitude larger [4]. That echoes when small language models beat frontier APIs with code.
- Probe concrete rows and verify a rule-based checklist: Never guess stored value formats or column semantics from schema names alone [7]. PV-SQL runs iterative probing queries to inspect concrete records, then extracts verifiable conditions into a rule-based executable checklist for iterative SQL refinement [7]. On BIRD benchmarks, PV-SQL outperformed the best baseline by 5% in correct SQL results (execution accuracy) and 20.8% in valid efficiency score while consuming fewer tokens [7].
- Replace raw scratchpads with structured semantic memory: Stop letting agents rediscover join logic on every run [8]. AgentSM captures prior execution traces or synthesizes curated ones as structured programs to guide future reasoning [8]. Compared with state-of-the-art systems on Spider 2.0, AgentSM cut average token usage 25% and reasoning paths (trajectory length) 35%, reaching 44.8% execution accuracy on Spider 2.0 Lite [8].
Even with strong controls, note the ceiling. Reaching 44.8% execution accuracy on Spider 2.0 Lite [8] or 30.1% with oracle hints on BEAVER [3] confirms that ad-hoc SQL over complex private warehouses cannot run unsupervised for finance reporting. High-stakes teams add read-only scopes, approved metric definitions, QA and verification gates, and verified workflow architecture.
Clean academic scores like 91.2% on Spider 1.0 [2] hide real warehouse failure [1] [2] [3]. Compressing schema clutter [6], gating unanswerable and ambiguous requests [4] [5], probing concrete rows against rule checklists [7], and reusing prior or curated traces [8] turn risky tools into governed analytics.
Frequently Asked Questions
Why does a model that passes academic SQL tests fail on an ERP warehouse?
Prevalent academic benchmarks like Spider and WikiSQL focus on tidy schemas with few rows of database contents [1]. Real enterprise warehouses often exceed 1,000 columns in systems like BigQuery and Snowflake and need multi-query SQL often exceeding 100 lines [2]. An o1-preview code agent drops from 91.2% on Spider 1.0 to 21.3% on Spider 2.0 [2], while GPT-5.2 agents score 10.8% across BEAVER's 812 private warehouse tables [3].
Does upgrading to a larger frontier model fix private database accuracy?
Model size alone does not solve private schemas. Across BEAVER's 9,128 real private query logs, GPT-5.2 agentic frameworks scored 10.8% accuracy and reached only 30.1% even with human hints for all 5 critical subtasks [3]. On BIRD, ACM researchers showed near-perfect schema linking lets a small SQL model almost match a model orders of magnitude larger [4].
Can a prompt rule stop an AI database tool from answering impossible questions?
Prompt-level refusal stays brittle because model hallucinations break output-level instruction following [5]. Unanswerable and underspecified questions may still generate executable SQL returning misleading numbers or violating safety constraints [5]. LatentRefusal gates answerability from hidden activations, averaging 88.5% (Llama-3.1-8B) and 88.8% (Qwen-3-8B) refusal F1 across 4 benchmarks while adding ~2ms probe overhead [5].
How much does compressing database metadata help large schemas?
Raw enterprise catalogs overwhelm leading models. On Spider 2.0-Snow and BIRD, DBCC shrank context up to two orders of magnitude (from 2.6M down to 34.7K tokens on the largest Spider 2.0-Snow subset), lifted strict schema-linking recall from 0% to 56.5% (DeepSeek-V3.2) and 63.1% (Claude Opus 4.7), and raised execution accuracy 1.8 to 1.9% over 3 recent systems [6].
Does checking concrete database rows and rule checklists raise token spend?
Structured probing and checklists can lower compute while boosting quality. On BIRD benchmarks, PV-SQL paired iterative row probing with a rule-based executable checklist, outperforming the best baseline by 5% in correct SQL results (execution accuracy) and 20.8% in valid efficiency score while consuming fewer tokens [7]. AgentSM also cut Spider 2.0 average token usage 25% and reasoning paths (trajectory length) 35% [8].
Primary Sources & Verification Ledger
08 VERIFIED CITATIONS-
[1]
Li, J., Hui, B., Qu, G., Yang, J., Li, B., Li, B., Wang, B., Qin, B., Geng, R., Huo, N., Zhou, X., Ma, C., Li, G., Chang, K., Huang, F., Cheng, R., & Li, Y. (2023). Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLs. Advances in Neural Information Processing Systems 36 (NeurIPS 2023).DOI VERIFIED doi.org/10.52202/075280-1835 ↗
-
[2]
Lei, F., Chen, J., Ye, Y., Cao, R., Shin, D., Su, H., Suo, Z., Gao, H., Hu, W., Yin, P., Zhong, V., Xiong, C., Sun, R., Liu, Q., Wang, S., & Yu, T. (2024). Spider 2.0: Evaluating Language Models on Real-World Enterprise Text-to-SQL Workflows. arXiv preprint.ARXIV VERIFIED arxiv.org/abs/2411.07763 ↗
-
[3]
Chen, P. B., Yang, D., Li, W., Wenz, F., Zhang, Y., Tatbul, N., Cafarella, M., Demiralp, Ç., & Stonebraker, M. (2024). BEAVER: An Enterprise Benchmark for Text-to-SQL. arXiv preprint.ARXIV VERIFIED arxiv.org/abs/2409.02038 ↗
-
[4]
Chen, K., Chen, Y., Koudas, N., & Yu, X. (2025). Reliable Text-to-SQL with Adaptive Abstention. Proceedings of the ACM on Management of Data.DOI VERIFIED doi.org/10.1145/3709719 ↗
-
[5]
Ren, X., Hu, S., Lu, Z., Huang, J., & Duan, Q. (2026). LatentRefusal: Latent-Signal Refusal for Unanswerable Text-to-SQL Queries. Findings of the Association for Computational Linguistics: ACL 2026.DOI VERIFIED doi.org/10.18653/v1/2026.findings-acl.1007 ↗
-
[6]
Liu, J., Liao, W., Gao, X., Zhao, J., & Wang, Y. (2026). Database Context Compression for Text-to-SQL on Real-World Large Databases. arXiv preprint.ARXIV VERIFIED arxiv.org/abs/2606.28601 ↗
-
[7]
Tian, Y., & Zhang, T. (2026). PV-SQL: Synergizing Database Probing and Rule-based Verification for Text-to-SQL Agents. Findings of the Association for Computational Linguistics: ACL 2026.DOI VERIFIED doi.org/10.18653/v1/2026.findings-acl.1286 ↗
-
[8]
Biswal, A., Lei, C., Qin, X., Li, A., Narayanaswamy, B., & Kraska, T. (2026). AgentSM: Semantic Memory for Agentic Text-to-SQL. arXiv preprint.ARXIV VERIFIED arxiv.org/abs/2601.15709 ↗