Seedlabs
Source research

VeriEQL: Bounded Equivalence Verification for Complex SQL Queries with Integrity Constraints

Yang He, P. Zhao, Xinyu Wang, Yuepeng Wang · 2024 · 13 citationsRead the paper

The task of SQL query equivalence checking is important in various real-world applications (including query rewriting and automated grading) that involve complex queries with integrity constraints; yet, state-of-the-art techniques are very limited in their capability of reasoning about complex features (e.g., those that involve sorting, case statement, rich integrity constraints, etc.) in real-life queries. To the best of our knowledge, we propose the first SMT-based approach and its implementation, VeriEQL, capable of proving and disproving bounded equivalence of complex SQL queries. VeriEQL is based on a new logical encoding that models query semantics over symbolic tuples using the theory of integers with uninterpreted functions. It is simple yet highly practical -- our comprehensive evaluation on over 20,000 benchmarks shows that VeriEQL outperforms all state-of-the-art techniques by more than one order of magnitude in terms of the number of benchmarks that can be proved or disproved. VeriEQL can also generate counterexamples that facilitate many downstream tasks (such as finding serious bugs in systems like MySQL and Apache Calcite).

What the full text shows

Working prototype
  • VeriEQL proved or disproved a significant majority of the total benchmarks evaluated. — over 70% of 24,455 benchmarks (Across LeetCode, Calcite, and Literature datasets)
  • VeriEQL outperformed state-of-the-art techniques in the number of benchmarks proved or disproved. — more than one order of magnitude (Compared against existing bounded equivalence checking techniques)
  • Existing state-of-the-art tools have very low coverage of real-world queries from LeetCode. — less than 2% (On the LeetCode dataset)
Setup
24,455 query pairs from three sources: LeetCode (23,994 pairs), Calcite optimization rules (397 pairs), and Literature (64 pairs). Average query size was 84.54 AST nodes.
How
The authors developed VeriEQL, an SMT-based approach using a new logical encoding that models query semantics over symbolic tuples. It utilizes the theory of integers with uninterpreted functions to prove or disprove bounded equivalence modulo integrity constraints.
Limitations
Does not support correlated subqueries in its current status.

Summarized by Gemma 4 from the open-access full text · 1 Nov 2026. Read it