mlsanityData to 14 Oct 2026

LLM-SQL-Solver: Can LLMs Determine SQL Equivalence?

arXiv 2312.10321 ↗First posted 16 Dec 2023cs.DB cs.CLcited by 10

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

  1. 2017Attention Is All You Needcited by 60,361
  2. 2020Language Models are Few-Shot Learnerscited by 32,419
  3. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
  4. 2022Chain-of-Thought Prompting Elicits Reasoning in Large Language Modelscited by 12,459
  5. 2023Judging LLM-as-a-Judge with MT-Bench and Chatbot Arenacited by 8,626
  6. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  7. 2022Self-Consistency Improves Chain of Thought Reasoning in Language Modelscited by 5,708
  8. 2022Training a Helpful and Harmless Assistant with Reinforcement Learning from Human Feedbackcited by 3,720
  9. 2023Tree of Thoughts: Deliberate Problem Solving with Large Language Modelscited by 3,211
  10. 2023Sparks of Artificial General Intelligence: Early experiments with GPT-4cited by 2,592
  11. 2023MMMU: A Massive Multi-discipline Multimodal Understanding and Reasoning Benchmark for Expert AGIcited by 2,080
  12. 2018Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-SQL Taskcited by 1,139
27 more
  1. 2023Large Language Models are not Fair Evaluatorscited by 1,085
  2. 2023Can Large Language Models Be an Alternative to Human Evaluations?cited by 734
  3. 2023Can LLM Already Serve as A Database Interface? A BIg Bench for Large-Scale Database Grounded Text-to-SQLscited by 688
  4. 2017Seq2SQL: Generating Structured Queries from Natural Language using Reinforcement Learningcited by 687
  5. 2023DIN-SQL: Decomposed In-Context Learning of Text-to-SQL with Self-Correctioncited by 477
  6. 2019RAT-SQL: Relation-Aware Schema Encoding and Linking for Text-to-SQL Parserscited by 424
  7. 2020AmbigQA: Answering Ambiguous Open-domain Questionscited by 390
  8. 2023Text-to-SQL Empowered by Large Language Models: A Benchmark Evaluationcited by 385
  9. 2022Language Models Are Greedy Reasoners: A Systematic Formal Analysis of Chain-of-Thoughtcited by 337
  10. 2023How Language Model Hallucinations Can Snowballcited by 311
  11. 2023ToolQA: A Dataset for LLM Question Answering with External Toolscited by 274
  12. 2023Is ChatGPT better than Human Annotators? Potential and Limitations of ChatGPT in Explaining Implicit Hate Speechcited by 166
  13. 2023C3: Zero-shot Text-to-SQL with ChatGPTcited by 164
  14. 2020Semantic Evaluation for Text-to-SQL with Distilled Test Suitescited by 126
  15. 2023Rephrase and Respond: Let Large Language Models Ask Better Questions for Themselvescited by 123
  16. 2023A comprehensive evaluation of ChatGPT's zero-shot Text-to-SQL capabilitycited by 119
  17. 2023GPT-4V(ision) as a Generalist Evaluator for Vision-Language Taskscited by 119
  18. 2021KaggleDBQA: Realistic Evaluation of Text-to-SQL Parserscited by 106
  19. 2020Grounded Adaptation for Zero-shot Executable Semantic Parsingcited by 76
  20. 2023CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translationcited by 57
  21. 2023CodeScope: An Execution-based Multilingual Multitask Multidimensional Benchmark for Evaluating LLMs on Code Understanding and Generationcited by 39
  22. 2018Apache Calcite: A Foundational Framework for Optimized Query Processing Over Heterogeneous Data Sourcescited by 25
  23. 2023Language Models can be Logical Solverscited by 24
  24. 2023LLM As DBAcited by 18
  25. 2018Axiomatic Foundations and Algorithms for Deciding Semantic Equivalences of SQL Queriescited by 11
  26. 2023From Words to Code: Harnessing Data for Program Synthesis from Natural Languagecited by 11
  27. 2023QueryBooster: Improving SQL Performance Using Middleware Services for Human-Centered Query Rewritingcited by 5

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 4; 2025: 5; 2026: 1.

10 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024Lucy: Think and Reason to Solve Text-to-SQL
  2. 2024From Natural Language to SQL: Review of LLM-based Text-to-SQL Systems
  3. 2025SQLForge: Synthesizing Reliable and Diverse Data to Enhance Text-to-SQL Reasoning in LLMs
  4. 2024Can LLMs substitute SQL? Comparing Resource Utilization of Querying LLMs versus Traditional Relational Databases
  5. 2025Weaver: Interweaving SQL and LLM for Table Reasoning
  6. 2025Play by the Type Rules: Inferring Constraints for LLM Functions in Declarative Programs
  7. 2025SLM-SQL: An Exploration of Small Language Models for Text-to-SQL
  8. 2024Evaluating and Enhancing LLMs for Multi-turn Text-to-SQL with Multiple Question Types