LLM-SQL-Solver: Can LLMs Determine SQL Equivalence?
Not on the map. Why?
Abstract (arXiv)
Judging the equivalence between two SQL queries is a fundamental problem with many practical applications in data management and SQL generation (i.e., evaluating the quality of generated SQL queries in text-to-SQL task). While the research community has reasoned about SQL equivalence for decades, it poses considerable difficulties and no complete solutions exist. Recently, Large Language Models (LLMs) have shown strong reasoning capability in conversation, question answering and solving mathematics challenges. In this paper, we study if LLMs can be used to determine the equivalence between SQL queries under two notions of SQL equivalence (semantic equivalence and relaxed equivalence). To assist LLMs in generating high quality responses, we present two prompting techniques: Miniature & Mull and Explain & Compare. The former technique is used to evaluate the semantic equivalence in which it asks LLMs to execute a query on a simple database instance and then explore if a counterexample exists by modifying the database. The latter technique is used to evaluate the relaxed equivalence in which it asks LLMs to explain the queries and then compare if they contain significant logical differences. Our experiments demonstrate using our techniques, LLMs is a promising tool to help data engineers in writing semantically equivalent SQL queries, however challenges still persist, and is a better metric for evaluating SQL generation than the popular execution accuracy.
Key facts. Cited by 10 papers in the map (data through 14 Oct 2026). Builds on 39 of its 74 references that are in the map. First posted on arXiv 16 Dec 2023.
Builds on
39 of 74 references.
References · 39
- 2017Attention Is All You Needcited by 60,361
- 2020Language Models are Few-Shot Learnerscited by 32,419
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
- 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
- 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
- 2021Evaluating Large Language Models Trained on Codecited by 8,320
- 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
- 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,720
- 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,211
- 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,592
- 2023MMMU: A Massive Multi-discipline Multimodal Understanding and Reasoning Benchmark for Expert AGIcited by 2,080
- 2018Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Taskcited by 1,139
27 more
- 2023Large Language Models are not Fair Evaluatorscited by 1,085
- 2023Can Large Language Models Be an Alternative to Human Evaluations?cited by 734
- 2023Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLscited by 688
- 2017Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learningcited by 687
- 2023DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correctioncited by 477
- 2019RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parserscited by 424
- 2020AmbigQA: Answering Ambiguous Open-domain Questionscited by 390
- 2023Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluationcited by 385
- 2022Language Models Are Greedy Reasoners: A Systematic Formal Analysis of Chain-of-Thoughtcited by 337
- 2023How Language Model Hallucinations Can Snowballcited by 311
- 2023ToolQA: A Dataset for LLM Question Answering with External Toolscited by 274
- 2023Is ChatGPT better than Human Annotators? Potential and Limitations of ChatGPT in Explaining Implicit Hate Speechcited by 166
- 2023C3: Zero-shot Text-to-SQL with ChatGPTcited by 164
- 2020Semantic Evaluation for Text-to-SQL with Distilled Test Suitescited by 126
- 2023Rephrase and Respond: Let Large Language Models Ask Better Questions for Themselvescited by 123
- 2023A comprehensive evaluation of ChatGPT's zero-shot Text-to-SQL capabilitycited by 119
- 2023GPT-4V(ision) as a Generalist Evaluator for Vision-Language Taskscited by 119
- 2021KaggleDBQA: Realistic Evaluation of Text-to-SQL Parserscited by 106
- 2020Grounded Adaptation for Zero-shot Executable Semantic Parsingcited by 76
- 2023CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translationcited by 57
- 2023CodeScope: An Execution-based Multilingual Multitask Multidimensional Benchmark for Evaluating LLMs on Code Understanding and Generationcited by 39
- 2018Apache Calcite: A Foundational Framework for Optimized Query Processing Over Heterogeneous Data Sourcescited by 25
- 2023Language Models can be Logical Solverscited by 24
- 2023LLM As DBAcited by 18
- 2018Axiomatic Foundations and Algorithms for Deciding Semantic Equivalences of SQL Queriescited by 11
- 2023From Words to Code: Harnessing Data for Program Synthesis from Natural Languagecited by 11
- 2023QueryBooster: Improving SQL Performance Using Middleware Services for Human-Centered Query Rewritingcited by 5
Built on by
Citing papers per year: 2024: 4; 2025: 5; 2026: 1.
10 papers.
- 2024From Generation to Judgment: Opportunities and Challenges of LLM-as-a-judgecited by 494
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checkingcited by 24
- 2024FLEX: Expert-level False-Less EXecution Metric for Reliable Text-to-SQL Benchmarkcited by 11
- 2025QUITE: A Query Rewrite System Beyond Rules with LLM Agentscited by 8
- 2025Text-to-SQL Domain Adaptation via Human-LLM Collaborative Data Annotationcited by 6
- 2024Hybrid Querying Over Relational Databases and Large Language Modelscited by 3
- 2026Barriers to Discrete Reasoning with Transformers: A Survey Across Depth, Exactness, and Bandwidthcited by 3
- 2024Can the Rookies Cut the Tough Cookie? Exploring the Use of LLMs for SQL Equivalence Checkingcited by 2
- 2025Taming SQL Complexity: LLM-Based Equivalence Evaluation for Text-to-SQLcited by 2
- 2025Access Paths for Efficient Ordering with Large Language Modelscited by 1
- 2026Barriers to Discrete Reasoning with Transformers: A Survey Across Depth, Exactness, and Bandwidth19 Jan 2026
- 2025Access Paths for Efficient Ordering with Large Language Models30 Aug 2025
- 2025Taming SQL Complexity: LLM-Based Equivalence Evaluation for Text-to-SQL11 Jun 2025
- 2025QUITE: A Query Rewrite System Beyond Rules with LLM Agents9 Jun 2025
- 2025Text-to-SQL Domain Adaptation via Human-LLM Collaborative Data Annotation21 Feb 2025
- 2025EquiBench: Benchmarking Large Language Models' Reasoning about Program Semantics via Equivalence Checking18 Feb 2025
- 2024Can the Rookies Cut the Tough Cookie? Exploring the Use of LLMs for SQL Equivalence Checking7 Dec 2024
- 2024From Generation to Judgment: Opportunities and Challenges of LLM-as-a-judge25 Nov 2024
- 2024FLEX: Expert-level False-Less EXecution Metric for Reliable Text-to-SQL Benchmark24 Sep 2024
- 2024Hybrid Querying Over Relational Databases and Large Language Models1 Aug 2024
Similar, not cited
Close in wording, no citation either way
- 2024Lucy: Think and Reason to Solve Text-to-SQL
- 2024From Natural Language to SQL: Review of LLM-based Text-to-SQL Systems
- 2025SQLForge: Synthesizing Reliable and Diverse Data to Enhance Text-to-SQL Reasoning in LLMs
- 2024Can LLMs substitute SQL? Comparing Resource Utilization of Querying LLMs versus Traditional Relational Databases
- 2025Weaver: Interweaving SQL and LLM for Table Reasoning
- 2025Play by the Type Rules: Inferring Constraints for LLM Functions in Declarative Programs
- 2025SLM-SQL: An Exploration of Small Language Models for Text-to-SQL
- 2024Evaluating and Enhancing LLMs for Multi-turn Text-to-SQL with Multiple Question Types