ModularSQL: A Runtime Guardrail for the Multiplicity Blind Spot in Text-to-SQL
Abstract
Text-to-SQL systems are increasingly deployed on production databases, where queries that pass benchmark evaluation can still produce results that distort downstream workflows. Standard set-based execution accuracy (Set-EX) collapses duplicate rows and can therefore miss multiplicity errors, including missing DISTINCT, inflated aggregates, and Cartesian-style join explosions. We call this the Multiplicity Blind Spot (MBS) and introduce Multiset-EX, a multiplicity-preserving evaluation criterion that exposes such failures. Across released DeepEye-SQL artifacts from three backbones (Qwen2.5-Coder-32B, Qwen3-Coder-30B-A3B, and Gemma-3-27B) on executable BIRD-Dev N=1532, we find a consistent 5.81--6.79 pp gap between Set-EX and Multiset-EX. The gap is not specific to DeepEye-SQL: it persists on released DAIL-SQL+GPT-4 (5.22 pp) and BIRD GPT-3.5-turbo (3.39 pp) predictions. We further introduce ModularSQL, a lightweight post-selection runtime guardrail that probes executed results for multiplicity anomalies and applies deterministic patches or low-cost LLM rescue only to flagged queries. Integrated with DeepEye-SQL using Qwen3-Coder, ModularSQL preserves Set-EX at 72.06% while improving Multiset-EX from 65.86% to 67.75% (+1.89 pp). It flags 77 high-risk anomalies, while adding only $0.0076 in total LLM cost and 120 ms amortized latency per query. Cross-pipeline evaluation shows that the candidate-free detector and deterministic patches also transfer to independently released prediction sets. Overall, these results show that benchmark accuracy does not necessarily imply execution-safe SQL, and that lightweight, multiplicity-aware runtime guardrails can narrow this gap with modest computational overhead.
Create a lesson
Metadata
- Comments
- 12 pages, 5 tables, 4 figures. Code: https://github.com/Ruixi1313/ModularSQL
Related papers
Are These Modules Worth Their Cost? A Paradigm-Level Accuracy-Cost Analysis of In-context Learning Text-to-SQL
Shared title terminologycs.CLJiayan Lin, Yujia Liu, Zijin Hong et al.
Beam Search, Self-Consistency, and the Limits of Inference-Time Scaling for Grammar-Constrained Text-to-SQL in Small Language Models
Shared title terminologycs.CLTy Chermsirivatana, John MacCormick
Technical Report MEG2text: Beyond Alignment in Non-Invasive Brain-to-Text
Shared title terminologycs.CLYiqian Yang, Yiqun Duan
Open-Source FUTO Keyboard Layouts and Predictive Text for a Few Endangered Languages
Shared title terminologycs.CLMika Hämäläinen, Jack Rueter, Khalid Alnajjar
Focus On Facts: Stylistically Invariant and Factually Sensitive Text Embeddings
Shared title terminologycs.CLMaximus Adeola
FOL-Proof: Verifying LLM Text-to-Logic Translations via Deterministic Semantics
Shared title terminologycs.CLYisrael Clark, Guy Katz