EntSQL: A Benchmark for Grounding Text-to-SQL in Long-Context Enterprise Knowledge

Chengxi Liao, Tao Xu, Zulong Chen, Chuanfei Xu, Yiyan Wang, Xinyun Wang, Yanlong Zhang, Xiaojun Chen, Zhibo Yang, Zeyi WenarXiv 2026

TL;DR

EntSQL is a new enterprise-oriented Text-to-SQL benchmark designed to evaluate how well large language models (LLMs) can ground database queries in long-context, proprietary business knowledge like internal metrics and reporting conventions. The benchmark reveals a massive capability gap: even state-of-the-art models and agentic workflows top out at just 15.9% execution accuracy when given full enterprise documents, highlighting that writing syntactically correct SQL is vastly different from understanding complex business logic.

What Problem Does This Paper Address?

While LLMs have become remarkably good at standard Text-to-SQL benchmarks (like Spider or BIRD), these datasets primarily test a model's ability to generalize to unseen database schemas or handle large-scale data. They largely ignore the messy reality of enterprise Business Intelligence (BI).

In a real company, a query like "Compare FY2024 and FY2025 revenue growth for top 10 products" cannot be answered by looking at the database schema alone. The model must know the company's specific fiscal year rules, internal definitions of "revenue growth," and product mapping policies. This private knowledge is typically buried in long-form internal documentation. EntSQL addresses this gap by shifting the evaluation focus from simple schema matching to long-context knowledge grounding.

Methods

The authors formalize the task as generating an executable SQL query given a natural language question, a database schema, and a long-form domain document.

To build a realistic benchmark, they developed a four-stage pipeline:

  1. Data Collection: Gathering authentic user Q&A logs across five core business domains.
  2. Context Synthesis & Expert Annotation: Domain experts annotated each query with the correct gold SQL, concise evidence snippets, and a synthesized domain document containing the necessary business rules.
  3. Anonymization & Translation: To protect proprietary data, a multi-level anonymization process masked sensitive entities (dates, monetary values, organizational units) across text and databases while preserving structural integrity. The data was also translated to create aligned Chinese-English pairs.
  4. Quality Control: Multi-stage manual reviews ensured high data fidelity.
Figure 1: Data construction pipeline. We collect enterprise queries, annotate SQL and domain evidence, anonymize sensitive content, and validate all annotations through multi-stage quality control.

The authors evaluated seven standalone LLMs (including Claude 4.6, GPT-5.4, Gemini 3.1 Pro, and Qwen 3.6 Max) and one advanced agentic framework (Claude Code) across three input settings: Question Only (Base), Question + Document (w/Doc), and Question + Concise Evidence (w/Evidence).

Datasets

The resulting dataset, EntSQL, consists of 1,066 aligned bilingual semantic examples spanning 5 domains (Treasury, Finance, Human Resources, Business Management, and Union/Party Building) and 15 subdomains. It features 15 database groups, 35 tables, and 1,489 columns.

Crucially, 96.0% of the examples require external domain knowledge to resolve. The queries are highly complex, averaging 388.7 tokens per gold SQL statement and heavily utilizing Common Table Expressions (CTEs), multi-table joins, and window functions.

Figure 2: Gold SQL profile in EntSQL. From left to right: feature distribution, gold SQL token-length statistics, and token-length-based difficulty distribution.

Key Insights and Ideas

  • Context Length $\neq$ Grounding Capability: Simply expanding the context window to fit long enterprise documents does not solve the problem. Models frequently get lost in the noise of long texts, struggling to isolate the specific business rule required for the query.
  • Retrieval is the Bottleneck: Providing models with concise, expert-curated evidence snippets (the w/Evidence setting) yields a significant performance boost over providing the full document. This indicates that localized knowledge selection is a major failure point.
  • Constraint Capture is the Dominant Failure Mode: An error analysis of failed predictions revealed that over half (54.6%) were due to WRONG_FILTER errors. Models aren't failing at basic SQL syntax; they are failing to correctly translate business constraints from the text into SQL WHERE or HAVING clauses.
Distribution of primary SQL-level error types, highlighting Wrong Filter as the main culprit.

Key Results

  • Baseline Performance is Near Zero: Without access to the domain documents (Base setting), the best system (Claude Code) achieved only 6.8% average execution accuracy, while standalone models hovered around 5%. For "Hard" queries, accuracy dropped to a dismal 0.8%.
  • Documents Help, But Not Enough: Introducing the long-form documents (w/Doc) improved Claude Code's accuracy to 15.9%, which was the top performance among all tested systems. Standalone models maxed out at 13.3% (Claude Opus).
  • Agentic Workflows Outperform Standalone Models: Claude Code consistently beat standalone models across all settings due to its ability to perform iterative tool use and execution-based self-correction.
  • Highly Skewed Domain Difficulty: Performance varied drastically by domain. In the w/Evidence setting, models achieved around 30.4% accuracy in Human Resources (which features simpler schemas) but collapsed to a near-zero 0.1% in Finance due to extreme query complexity.
Figure 3: Domain-wise execution accuracy (%) aver- aged over all evaluated systems on English examples. Performance is highly skewed across domains, and con- cise evidence brings large but uneven gains.

Limitations and Future Work

The authors note that EntSQL is drawn from a single enterprise setting across five domains, meaning it may not capture every variation of corporate data structures. Additionally, the local evaluation databases do not fully simulate production challenges like access control, latency constraints, or multi-turn user clarifications.

Future research directions suggested by the work include developing explicit intermediate representations for complex query planning, engineering stronger grounding mechanisms for domain-specific business rules, and building post-generation validation modules to verify schema and document constraints before execution.

Summary updated

BibTeX
@misc{liao2026entsql,
  author = {Chengxi Liao and Tao Xu and Zulong Chen and Chuanfei Xu and Yiyan Wang and Xinyun Wang and Yanlong Zhang and Xiaojun Chen and Zhibo Yang and Zeyi Wen},
  title = {{EntSQL: A Benchmark for Grounding Text-to-SQL in Long-Context Enterprise Knowledge}},
  year = {2026},
  eprint = {2606.03363},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2606.03363},
}
Figure