Engineering Reliable LLM-Based Data Analysis: An Empirical Study of Schema Grounding, Planning, Verification, and SQL Repair

Large Language Models (LLMs) can generate executable analytical SQL while still producing incorrect results because of schema, join, aggregation, filtering, dialect, and semantic errors. This paper presents an empirical study of architectural mechanisms for improving the reliability of LLM-generated analytical SQL, focusing on schema grounding, structured planning, AST-based structural verification, and automated SQL repair. We evaluate a multi-stage reliability pipeline on a frozen 500-query benchmark spanning eight business domains over a relational e-commerce warehouse constructed from the Brazilian Olist public dataset. Under the study's row-multiset result-equivalence comparator, the system achieves a 73.40% Result Equivalence Rate (367/500), 31.00% Exact Match, and 100.00% SQL Execution Success, with mean latency of 64.04 seconds. A controlled 100-query component ablation shows that adding AST-based structural verification to unverified planning improves result equivalence from 15.0% to 26.0% (McNemar's p = 0.0192; odds ratio = 3.75). An audit of 101 verifier-triggered repair cases shows that automated repair is a double-edged mechanism: 97/101 post-repair queries were syntactically valid, but 22 previously correct queries were degraded while only 4 incorrect queries were genuinely recovered. A controlled 50-query synthetic perturbation study further shows substantial vulnerability to typographical noise, with 57.1% retention under typo perturbations. These results support conservative, uncertainty-aware structural verification and repair rather than unrestricted automated self-correction. The study is limited to a single relational schema and custom benchmark and does not establish cross-domain or enterprise-wide generalization.

Authors

Publication Details

Journal
Zenodo (CERN European Organization for Nuclear Research)
Published
2026-08-20
DOI
https://doi.org/10.5281/zenodo.22012436
Primary Topic
Advanced Database Systems and Queries
Type
preprint
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
preprint

Engineering Reliable LLM-Based Data Analysis: An Empirical Study of Schema Grounding, Planning, Verification, and SQL Repair

Mevin Jose
Zenodo (CERN European Organization for Nuclear Research)
Advanced Database Systems and Queries
preprint

Engineering Reliable LLM-Based Data Analysis: An Empirical Study of Schema Grounding, Planning, Verification, and SQL Repair

Mevin Jose
preprint en

Abstract

Large Language Models (LLMs) can generate executable analytical SQL while still producing incorrect results because of schema, join, aggregation, filtering, dialect, and semantic errors. This paper presents an empirical study of architectural mechanisms for improving the reliability of LLM-generated analytical SQL, focusing on schema grounding, structured planning, AST-based structural verification, and automated SQL repair. We evaluate a multi-stage reliability pipeline on a frozen 500-query benchmark spanning eight business domains over a relational e-commerce warehouse constructed from the Brazilian Olist public dataset. Under the study's row-multiset result-equivalence comparator, the system achieves a 73.40% Result Equivalence Rate (367/500), 31.00% Exact Match, and 100.00% SQL Execution Success, with mean latency of 64.04 seconds. A controlled 100-query component ablation shows that adding AST-based structural verification to unverified planning improves result equivalence from 15.0% to 26.0% (McNemar's p = 0.0192; odds ratio = 3.75). An audit of 101 verifier-triggered repair cases shows that automated repair is a double-edged mechanism: 97/101 post-repair queries were syntactically valid, but 22 previously correct queries were degraded while only 4 incorrect queries were genuinely recovered. A controlled 50-query synthetic perturbation study further shows substantial vulnerability to typographical noise, with 57.1% retention under typo perturbations. These results support conservative, uncertainty-aware structural verification and repair rather than unrestricted automated self-correction. The study is limited to a single relational schema and custom benchmark and does not establish cross-domain or enterprise-wide generalization.

Zenodo (CERN European Organization for Nuclear Research)
Advanced Database Systems and Queries
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.