Official statistics are critical datasets for a wide variety of actors, including policymakers and businesses. For providers of official statistics, improving accessibility, governance, and disclosure of their data is of key importance. This can be improved by providing question-answering systems based on text-to-SQL approaches. However, existing text-to-SQL benchmarks do not resemble this setting. Official statistics are published as open-domain catalogs of thousands of wide tables whose columns and values are codes, and whose meaning is recorded in separate metadata rather than in a relational schema. To address this gap, we introduce LOCuST, a text-to-SQL benchmark that pairs over two thousand English and Dutch tables from Statistics Netherlands with a semantic knowledge graph. The graph describes the tables, measures, and dimension codes through labels, definitions, hierarchies, and units, and is the external knowledge a system needs to find the right tables and ground a question in the right codes. The benchmark includes expert-annotated questions for different query and aggregation types, including raw value retrieval, summations, proportion calculations, and joins. Alongside standard evaluation measures, we introduce an observation F1 metric that measures how close a query is to the ground truth even when the answers are different. We evaluate a variety of state-of-the-art LLMs and find that they struggle to write SQL that answers the questions correctly.
Figures & tables
Dataset
# Queries
# Tables ∗∗
Average # Cols/Table
Median # Cols/Table
Language
External knowledge
Spider [ 6 ]
10,181
995
5.10
4
en
✗
Spider2.0-snow [ 7 ]
547
5,137
28.11
10
en
External documents
BIRD [ 8 ]
10,962
597
7.26
5
en
Evidence sentences
BULL [ 9 ]
4,966
78
14.96
13
en, zh
Schema descriptions
BEAVER [ 10 ]
7,978
381
9.50
7
en
Domain-knowledge annotations
StatBot.Swiss [ 11 ]
456
36
6.94
5
en, de
Schema descriptions
TABLE I : Statistics for popular text-to-SQL datasets, ∗ showing the number of queries, tables, the average number of columns per table and how datasets cover a requirement for using external knowledge.
TABLE II : Example OData3 table and query result.
Fig. 1 : Schematic overview of the semantic graph for table 03753eng (School size by type of education and ideological basis). For brevity, only a selection of graph objects and predicates are shown. All measures and dimensions have concepts with labels and definitions that can be given to a model. Measures are highlighted in orange, dimension groups in dark green and connected dimension codes in light green.
Fig. 2 : Distribution of number of measures + dimensions that need to be searched for each question-answer pair’s relevant tables.
English
Dutch
Total triples
1,701,066
6,531,863
Tables
1,030
1,211
Tables with geo dim.
139
362
Tables with time dim.
1,012
1,068
Unique measures
21,157
15,400
Measure-table links
29,886
36,816
TABLE III : Metadata graph statistics for both languages
Fig. 3 : Overview of the annotation workflow and tasks involved in the benchmark.
@2
@5
@10
Model
R
PR
R
PR
R
PR
en
BM25+
0.25
0.22
0.36
0.33
0.44
0.40
ColBERTv2
0.62
0.56
0.71
0.65
0.77
0.71
nl
BM25+
0.11
0.11
0.14
0.13
0.17
0.16
ColBERTv2
0.40
0.36
0.61
0.56
0.75
0.71
TABLE IV : Baseline table retrieval performances.
TABLE V : Query generation and end-to-end results on all baseline models for the English (en) and Dutch (nl) datasets.
Fig. 4 : Execution accuracies and measure, dimension and observation F1 scores for each baseline model broken down by question type for the end-to-end task.
Metric
EX S
EX L
NF1
msr F1
dim F1
obs F1
EX S
0.83
0.31
0.15
0.18
0.22
EX L
0.83
0.37
0.17
0.20
0.24
NF1
0.31
0.37
0.43
0.54
0.63
msr F1
0.15
0.17
0.43
0.34
0.72
dim F1
0.18
0.20
0.54
0.34
0.81
obs F1
0.22
0.24
0.63
0.72
0.81
TABLE VI : Spearman correlation between the (lenient) evaluation metrics on the query generation and end-to-end task, over all questions with a generated query. ∗
TABLE VII : Number of queries, syntax errors, and wrongly chosen aggregations for each question type, and syntax errors for each domain of the test questions for all models on the English test set (end-to-end QA task). Syntax errors and percentages are relative to the number of generated queries, wrong aggregations to the generated queries without a syntax error.
Error type
Claude 5
GPT 6
LLama 4
Qwen 3.8
No query generated
0.0
0.0
1.0
0.0
Syntax errors
2.6
1.0
6.5
7.7
Incorrect table(s) ∗
4.3
3.6
4.2
5.9
Wrong aggregation ∗
8.6
4.6
19.9
11.5
Missing measures
10.6
8.4
15.6
13.9
Extra measure(s)
10.6
9.0
13.4
13.2
TABLE VIII : Common mistakes per model on the query generation task on the English test set, as a percentage of the generated queries (‘No query generated’ as a percentage of all questions).
Less than 101 pupils/students
Roman Catholic
Primary schools
Measure
Unit
AVG[‘Periods’ ]
Enrolled students
number
13755.0
TABLE IX : Query result for Example 2, pivoted over the measure (orange). Colors indicate dimension codes (light green) and the observation (blue). Labels and units are obtained from the semantic graph.
Model
EX S
EX L
msr F1
dim F1
obs F1
en
Claude 5
0.07−0.05
0.31+0.15
0.81−0.08
0.81−0.09
0.76−0.08
GPT 6
0.08−0.02
0.38+0.28
0.75−0.17
0.76−0.16
0.72−0.15
LLama 4
0.03
0.13+0.07
0.57−0.25
0.56−0.24
0.53−0.20
Qwen 3.8
0.09
0.25+0.14
0.64−0.18
0.64−0.17
0.61−0.14
nl
Claude 5
0.05−0.01
0.21+0.11
0.77−0.15
0.68−0.12
0.68−0.12
GPT 6
0.04−0.03
0.27+0.17
0.76−0.19
0.68−0.16
0.67−0.17
TABLE X : Performance for all models on the query-only generation task with a pivoting requirement. An increase or decrease to the performances of the regular SQL generations are indicated with + and - respectively.
While recent Large Language Model (LLM)-based text-to-SQL systems achieve impressive performance on standard benchmarks, they struggle when user queries implicitly rely on domain-specific knowledge, such as business logic, data conventions, and analytical practices, that is neither captured by the schema nor explicitly stated in the natural language question. Historical SQL query logs offer a valuable source of such knowledge, yet existing benchmarks do not adequately support evaluation of history-driven approaches. To address this gap, we introduce BIRD-History, a benchmark consisting of 1,393 tasks across 11 databases, designed to evaluate text-to-SQL systems' ability to ground underspecified natural language questions using historical SQL scripts. Each task is annotated with ground-truth labels specifying which historical queries contain relevant knowledge and which SQL clauses encode it, enabling systematic evaluation of both retrieval effectiveness and knowledge utilization. Alongside the benchmark, we propose a plug-in retriever that extracts five types of external knowledge from historical SQL scripts, then retrieves and reranks relevant fragments for query generation. The retriever integrates seamlessly into existing few-shot text-to-SQL pipelines without requiring prompt modifications. Experiments demonstrate consistent improvements across four text-to-SQL systems, highlighting the value of leveraging historical query logs for handling underspecified queries. Dataset and code are open-sourced on https://github.com/zjuidg/BIRD-History.
Yunfan Zhou, Qiming Shi, Yizhou Yang +2
State Key Lab of CAD&CG, Zhejiang University · School of Software Technology, Zhejiang University
Text-to-SQL enables natural language access to databases, and recent LLMs have substantially advanced its capabilities. Existing benchmarks such as Spider, BIRD, and Spider~2.0 evaluate schema generalization, large-scale databases, and realistic workflows, but largely overlook enterprise scenarios where SQL generation depends on private business knowledge, such as internal metrics, reporting conventions, and organizational rules. We introduce EntSQL, an enterprise-oriented Text-to-SQL benchmark for evaluating long-context grounding over proprietary business documents. EntSQL contains 1,066 aligned Chinese-English semantic examples across five business domains, with most examples requiring domain knowledge beyond the question and schema and involving complex SQL structures. On English inputs, the best evaluated system reaches only 15.9% when long-form documents are provided, highlighting the difficulty of grounding SQL generation in enterprise knowledge.
Chengxi Liao, Tao Xu, Zulong Chen +7
1HKUST (GZ) · 2Alibaba Group · 4Guangdong Laboratory of Artificial Intelligence and Digital Economy (SZ) +1
LLM-based agents for text-to-SQL often struggle with latency-performance trade-off, where performance improvements come at the cost of latency or vice versa. We reformulate text-to-SQL generation within the lens of software test coverage where the original query is prepared with a suite of test cases with simpler, atomic SQLs that are executed in parallel and together ensure semantic coverage of the original query. After iterating on test case coverage, the final SQL is generated only when enough information is gathered, leveraging the explored test case SQLs to ground the final generation. We validated our framework on a state-of-the-art benchmark for text-to-SQL, Spider 2.0, achieving a new state-of-the-art with 70.2% execution accuracy.