A Text-to-SQL Benchmark for Official Statistics

Lucas Lageweg, Karen Goes, Tom van den Broek, Frank Pijpers, Paul Groth, Jan-Christoph KaloarXiv 2026

TL;DR

Translating natural language into database queries (text-to-SQL) looks like a nearly solved problem on standard academic leaderboards—until you point a model at real-world government statistics. This paper introduces LOCuST, a massive English and Dutch benchmark built on official data from Statistics Netherlands, where tables are wide, filled with cryptic alphanumeric codes, and require a separate semantic knowledge graph just to decipher. When tested on this realistic open-domain catalog, frontier LLMs struggle mightily, achieving at best 10% execution accuracy and revealing a massive gap between neat academic benchmarks and messy institutional reality.

What Problem Does This Paper Address?

Official statistics—census numbers, inflation rates, energy consumption—are the bedrock of policymaking and business decisions. Making this data accessible via natural language (text-to-SQL) would be transformative.

However, existing text-to-SQL benchmarks (like Spider or BIRD) live in a clean, idealized world. They typically hand the model the exact database it needs to query, use narrow tables (4–5 columns) with self-explanatory names like student_age, and cover everyday internet topics like sports or retail.

Official statistics look nothing like this. Statistical agencies publish open-domain catalogs containing thousands of wide, denormalized tables (some exceeding 1,200 columns). Instead of readable text, cells and columns are populated with opaque identifiers like A041907 or 2022SJ00.

TABLE II: Example OData3 table and query result.

Furthermore, statistical jargon is subtle: "green energy" might include biomass in one table and exclude it in another, and you cannot mathematically sum percentages with raw counts. To write valid SQL here, a system has to hunt through thousands of tables, look up definitions and units in external metadata, and ground user questions in exact codes. Prior benchmarks simply do not test this pipeline.

Methods

The authors structure LOCuST around a realistic three-stage task environment and pair it with a custom evaluation framework:

Fig. 3: Overview of the annotation workflow and tasks involved in the benchmark.
  1. Three-Stage Pipeline: Systems are evaluated on Table Retrieval (finding the right tables out of 1,000+ candidates), Query Generation (writing SQL when handed the golden tables), and End-to-End QA (doing both sequentially).
  2. Semantic Knowledge Graph: The authors hand-crafted an RDF knowledge graph from Statistics Netherlands' APIs using standard ontologies (Data Cube, SKOS, QUDT). It links cryptic table codes to human-readable labels, definitions, hierarchies (e.g., municipality X is part of province Y), and measurement units—allowing the framework to automatically flag nonsensical math, like summing incompatible units.
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.
  1. Observation F1 (obsF1) Metric: Standard Execution Accuracy (EX) is brutally binary: if your SQL output has one extra descriptive column or slightly different formatting, you get a zero. The authors introduce novel F1 metrics (msrF1, dimF1, and combined obsF1) by parsing the SQL AST and checking it against the knowledge graph to measure whether the query selected the right underlying data observations, regardless of final formatting or aggregation errors.
  2. Baselines: For retrieval, they test sparse BM25+ against a dense ColBERTv2 model trained with hard-negative mining. For SQL generation, they serialize relevant subgraphs into hierarchical prompts and test four out-of-the-box LLMs using few-shot prompting: Claude 5 Sonnet, GPT 6 Sol, Llama 4 Maverick, and Qwen 3.8-27B.

Datasets

The paper introduces LOCuST (Large-scale Official statistics Complex text-to-SQL Task), built on real Open Data tables from Statistics Netherlands (CBS) stored as Parquet files for DuckDB execution:

  • Scale & Languages: Spans 22 domains with 1,299 English queries (over 1,030 tables, averaging 32.4 columns) and 1,260 Dutch queries (over 1,211 tables, averaging 34.55 columns). The Dutch metadata graph is notably larger (~6.5M triples vs. ~1.7M in English) due to granular neighborhood-level data.
  • Domain-Holdout Split: Six entire domains (e.g., Energy, Education, Manufacturing) are held out exclusively for the test set (308 English, 299 Dutch questions) to test true domain transfer while keeping all 1,000+ tables in the retrieval pool.
  • Expert Annotation: Queries were generated via randomized S-expressions across 8 complexity types (from simple VALUE lookups to multi-table AGGJOIN and PROP proportion calculations), drafted into natural language by GPT-4.1, and manually verified or rewritten by four experts at Statistics Netherlands.
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.

Key Insights and Ideas

  • Models find the right neighborhood, then trip at the finish line: Why is Execution Accuracy near 10% while obsF1 reaches up to 87% (when given the right table)? Models are actually decent at identifying the primary measure, almost getting the right answer, and then missing a single dimension filter—or formatting the output columns differently than expected. Binary EX hides this nuance completely; obsF1 exposes it.
  • Dimension grounding is the universal bottleneck: Models rarely invent syntax errors in standard SQL (only 6.5% fail to execute, mostly column-binding mistakes). Instead, the #1 failure mode is missing an expected dimension filter or picking the wrong dimension code. Crucially, all four models fail on the exact same questions (45 in English, 79 in Dutch), proving the difficulty lies in navigating ambiguous statistical metadata rather than model-specific quirks.
  • Pivoting breaks SQL parsers, not data selection: Official statistics routinely present data as 2D pivoted tables. When the authors ran an ablation requiring PIVOT SQL syntax, underlying data selection (lenient obsF1) didn't budge, but syntax errors skyrocketed over 4x (from 158 to 651 queries).
  • Sparse search drowns in boilerplate: Standard keyword search (BM25+) fails badly at table retrieval—especially in Dutch—because statistical tables share tons of identical methodological boilerplate text, differing only by a single reported year or regional level. Dense retrieval (ColBERTv2) handles this disambiguation far better.

Key Results

  • Table Retrieval: ColBERTv2 achieves a Recall@5 of 0.71 (English) and 0.61 (Dutch), decisively outperforming BM25+ (0.36 English, 0.14 Dutch).
  • End-to-End QA: Performance is sobering across all frontier LLMs. In English, GPT 6 Sol leads with 0.10 strict EX (0.11 lenient EX), 0.52 numeric F1, and 0.62 obsF1. In Dutch, Qwen 3.8 hits the highest strict EX at just 0.05, while GPT 6 Sol leads in obsF1 at 0.62 (with 0.03 strict EX).
  • Oracle Query Generation: Even when handed the exact ground-truth tables, models top out at 0.12 strict EX / 0.16 lenient EX (Claude 5 on English), though GPT 6 reaches 0.87 obsF1 (English) and 0.84 obsF1 (Dutch). Multi-table joins (AGGJOIN) are brutal: 0% of end-to-end answers are fully correct.

Limitations and Future Work

  • Verbose LLM-assisted phrasings: Because GPT-4.1 drafted the initial question suggestions, English questions tended to be overly verbose and literal compared to how real, casual users type queries. Interestingly, because GPT-4.1 struggled with Dutch, human experts had to manually rewrite Dutch questions much more heavily, inadvertently making the Dutch phrasing more creative and ambiguous.
  • Unanswerable questions: Real users frequently ask statistical agencies impossible questions—requesting sums of incompatible units, querying retracted data, or relying on false premises (e.g., "Which Dutch cities have more inhabitants than Amsterdam?"). While LOCuST's knowledge graph already supports detecting incompatible unit aggregations, the current test set only evaluates answerable queries. Future work aims to incorporate unanswerable and false-premise questions directly into the benchmark.

Summary updated

Abstract

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.
BibTeX
@misc{lageweg2026text,
  author = {Lucas Lageweg and Karen Goes and Tom van den Broek and Frank Pijpers and Paul Groth and Jan-Christoph Kalo},
  title = {{A Text-to-SQL Benchmark for Official Statistics}},
  year = {2026},
  eprint = {2611.32646},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.32646},
}
Figure