Proving Query Equivalence Using Linear Integer Arithmetic
Haoran Ding, Zhaoguo Wang, Yicun Yang, Dexin Zhang, Zhenglin Xu, Haibo Chen, Ruzica Piskac, Jinyang Li
摘要
Proving the equivalence between SQL queries is a fundamental problem in database research. Existing solvers model queries using algebraic representations and convert such representations into first-order logic formulas so that query equivalence can be verified by solving a satisfiability problem. The main challenge lies in "unbounded summations", which appear commonly in a query's algebraic representation in order to model common SQL features, such as Projection and aggregate functions. Unfortunately, existing solvers handle unbounded summations in an ad-hoc manner based on heuristics or syntax comparison, which severely limits the set of queries that can be supported. This paper develops a new SQL equivalence prover called SQLSolver, which can handle unbounded summations in a principled way. Our key insight is to use the theory of LIA * , which extends linear integer arithmetic formulas with unbounded sums and provides algorithms to translate a LIA * formula to a LIA formula that can be decided using existing SMT solvers. We augment the basic LIA * theory to handle several complex scenarios (such as nested unbounded summations) that arise from modeling real-world queries. We evaluate SQLSolver with 359 equivalent query pairs derived from the SQL rewrite rules in Calcite and Spark SQL. SQLSolver successfully proves 346 pairs of them, which significantly outperforms existing provers.
问 Lune
几分钟读透这篇 Paper,不用再花一下午。
Lune 能读完全文,也能读引用它的顶会 Paper,讲清它的结论、证据和局限,每一点都注明出自哪篇 Paper。不用硬啃,也不靠猜。
已有 14 篇顶会 Paper 引用了它。别等审稿人问起,先弄清它们发现了什么。
脉络
- Automated Validating and Fixing of Text-to-SQL Translation with Execution Consistency 引用了 SPES: A Symbolic Approach to Proving Query Equivalence Under Bag Semantics
- Automated Validating and Fixing of Text-to-SQL Translation with Execution Consistency 引用了 WeTune: Automatic Discovery and Verification of Query Rewrite Rules
- Proving Cypher Query Equivalence 引用了 SPES: A Symbolic Approach to Proving Query Equivalence Under Bag Semantics
- Proving Cypher Query Equivalence 引用了 WeTune: Automatic Discovery and Verification of Query Rewrite Rules
- GenRewrite: Query Rewriting via Large Language Models 引用了 A Learned Query Rewrite System using Monte Carlo Tree Search
- GenRewrite: Query Rewriting via Large Language Models 引用了 WeTune: Automatic Discovery and Verification of Query Rewrite Rules
- Beyond Relational: Semantic-Aware Multi-Modal Analytics with LLM-Native Query Optimization 引用了 Automated Validating and Fixing of Text-to-SQL Translation with Execution Consistency
- WeTune: Automatic Discovery and Verification of Query Rewrite Rules 引用了 A Learned Query Rewrite System using Monte Carlo Tree Search
- WeTune: Automatic Discovery and Verification of Query Rewrite Rules 引用了 SQLCheck: Automated Detection and Diagnosis of SQL Anti-Patterns
引用它的顶会 Paper14
- GenRewrite: Query Rewriting via Large Language ModelsJie Liu, Barzan MozafariSIGMOD 2026 · 27 次引用
- Beyond Relational: Semantic-Aware Multi-Modal Analytics with LLM-Native Query OptimizationJunhao Zhu, Lu Chen, Xiangyu Ke, Ziquan Fang 等SIGMOD 2026 · 8 次引用
- Automated Validating and Fixing of Text-to-SQL Translation with Execution ConsistencyYicun Yang, Zhaoguo Wang, Yu Xia, Zhuoran Wei 等SIGMOD 2025 · 7 次引用
- Proving Cypher Query EquivalenceLei Tang, Wensheng Dou, Yingying Zheng, Lijie Xu 等ICDE 2025 · 3 次引用
- Checking Observational Correctness of Database SystemsLauren Pick, Amanda Xu, Ankush Desai, Sanjit A. Seshia 等OOPSLA 2025 · 2 次引用
它引用的 Paper4
- A Learned Query Rewrite System using Monte Carlo Tree SearchXuanhe Zhou, Guoliang Li, Chengliang Chai, Jianhua FengVLDB 2022 · 85 次引用
- WeTune: Automatic Discovery and Verification of Query Rewrite RulesZhaoguo Wang, Zhou Zhou, Yicun Yang, Haoran Ding 等SIGMOD 2022 · 35 次引用
- SQLCheck: Automated Detection and Diagnosis of SQL Anti-PatternsPrashanth Dintyala, Arpit Narechania, Joy ArulrajSIGMOD 2020 · 26 次引用
- SPES: A Symbolic Approach to Proving Query Equivalence Under Bag SemanticsQi Zhou, Joy Arulraj, Shamkant B. Navathe, William Harris 等ICDE 2022 · 19 次引用
相关 Paper
- VeriEQL: Bounded Equivalence Verification for Complex SQL Queries with Integrity ConstraintsYang He, Pinhan Zhao, Xinyu Wang, Yuepeng WangOOPSLA 2024 · 12 次引用
- QED: A Powerful Query Equivalence Decider for SQLShuxian Wang, Sicheng Pan, Alvin CheungVLDB 2024 · 19 次引用
- Polygon: Symbolic Reasoning for SQL using Conflict-Driven Under-Approximation SearchPinhan Zhao, Yuepeng Wang, Xinyu WangPLDI 2025
- Ramsey Quantifiers in Linear ArithmeticsPascal Bergsträßer, Moses Ganardi, Anthony W. Lin, Georg ZetzschePOPL 2024 · 2 次引用
- Translating canonical SQL to imperative code in CoqVéronique Benzaken, Evelyne Contejean, Mohammed Houssem Hachmaoui, Chantal Keller 等OOPSLA 2022 · 3 次引用
