Can the Rookies Cut the Tough Cookie? Exploring the Use of LLMs for SQL Equivalence Checking
Rajat Singh, Srikanta Bedathur

TL;DR
This paper investigates the use of large language models (LLMs) for SQL query equivalence checking, introducing a new benchmark and demonstrating that LLMs significantly outperform formal models, though they struggle with non-equivalent pairs.
Contribution
The paper presents a novel benchmark for complex SQL equivalence checking and evaluates LLMs' reasoning capabilities, revealing their strengths and limitations in this domain.
Findings
LLMs achieve up to 82% accuracy on SQL equivalence tasks.
LLMs support full coverage of complex SQL queries beyond formal models.
LLMs show bias towards predicting equivalence, with poor performance on non-equivalent pairs.
Abstract
Equivalence checking of SQL queries is an intractable problem often encountered in settings ranging from grading SQL submissions to debugging query optimizers. Despite recent work toward developing practical solutions, only simple queries written using a small subset of SQL are supported, leaving the equivalence checking of sophisticated SQL queries at the mercy of intensive, potentially error-prone, manual analysis. In this paper, we explore how LLMs can be used to reason with SQL queries to address this challenging problem. Towards this, we introduce a novel, realistic, and sufficiently complex benchmark called SQLEquiQuest for SQL query equivalence checking that reflects real-world settings. We establish strong baselines for SQL equivalence checking by leveraging the ability of LLMs to reason with SQL queries. We conduct a detailed evaluation of several state-of-the-art LLMs using…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsMathematics, Computing, and Information Processing · Advanced Database Systems and Queries · Service-Oriented Architecture and Web Services
MethodsRefunds@Expedia|||How do I get a full refund from Expedia? · Attention Is All You Need · Dropout · Attention Dropout · Position-Wise Feed-Forward Layer · Softmax · Cosine Annealing · Byte Pair Encoding · Linear Layer · Linear Warmup With Cosine Annealing
