Search arXiv⌕ Search

arXiv · 2610.30100

Building SQL Equivalence Proofs from Query Rewrite Rules

Abstract

Query rewriting and semantic evaluation of text-to-SQL systems both depend on deciding whether two SQL queries return the same result on every database satisfying the schema constraints. Decades of equivalence-preserving optimizer rules provide a natural basis for constructive proofs: two queries are equivalent when admitted rewrites transform them to a common logical expression. Building on this observation, \sys{} organizes query-rewriting knowledge as a standalone proof-producing system. It separates rule validation from proof discovery, explicitly aligns alternative query representations, and returns the resulting rewrite derivation. Across three corpus classes, EquiTrace proves 648/1,106 expected-equivalent text-to-SQL pairs (58.6%), 229/266 curated pairs (86.1%), and 97/240 LLM-generated rewrites whose results agree under benchmark execution (40.4%). On the query rewrite corpus, EquiTrace proves 97 pairs, compared with 35 for QED and 38 for SQLSolver. An analysis of 1,242 recorded proofs shows that coverage depends on a small number of transformations, while many frequently used rules are individually substitutable. The resulting derivations make each proof replayable and expose the specific transformations on which it depends.

Explore related subjects

Keep this discovery

Explore connections, maps & timelines

BibTeXRIS

Chunyu Chen, Xinyi Huang, Zhengjie Miao. 2026-10-21. Building SQL Equivalence Proofs from Query Rewrite Rules. https://arxiv.org/abs/2610.30100

Cite the original work for its findings. Save a collection to share your selection of sources.

KEEP EXPLORING

Related papers

An Agentic Approach to Metadata Reasoning

As autonomous LLM agents evolve to perform complex analytical tasks that require integrating multiple datasets, the problem of discovering relevant data sources becomes a key bottleneck. Beyond the challenge posed by the sheer volume of available data sources, data-source selection is difficult because the semantics of data are nuanced and require considering many aspects of the data. To address this challenge, we introduce Metadata Reasoner, an agentic approach to metadata reasoning that identifies a small set of data sources that are both sufficient and minimal for a given analytical task. Metadata Reasoner leverages a table-search engine to retrieve candidate tables, and then autonomously consults various aspects of the available metadata to determine whether the candidates fit the requirements of the task. We demonstrate the effectiveness of Metadata Reasoner through a series of empirical studies. Evaluated on the real-world KramaBench datasets for data selection, our approach achieves an average F1 score of 88.63%, outperforming the strongest baseline by 10.73 percentage points. Furthermore, evaluations on a newly created synthetic benchmark based on the BIRD dataset reveal that Metadata Reasoner is highly robust against redundant and low-quality tables that are in the data lake. In this noisy environment, Metadata Reasoner maintains a 93.5% average F1 score for selecting the right datasets and demonstrates a 100% success rate in avoiding low-quality data. Finally, we extend Metadata Reasoner to support the interleaving of table selection with the execution of partial queries. Compared with a single pass of table selection, such interleaving improves table-selection F1 score on runtime-dependent tasks by 4.8 percentage points and end-to-end task accuracy by 5.3 points.

cs.DB↗

TT-SAX: A Two-Track Time Series Symbolization for Natural Language Shape Querying

Natural language querying for time series databases aims to let users find what they need in long histories of data by asking in plain language. Shape queries ask how a series moves. They are the main challenge of this task. Recent work makes them feasible by using symbolization as a bridge between the query and the long history. However, existing symbolizations were designed for compression, similarity indexing, or classification. What a symbolization should provide for natural language querying has not been systematically studied. We therefore examine the definitions of six classical symbolizations against this task and identify three limitations. (1) Direction is missing from the string, (2) direction is measured at too small a scale, and (3) the letters are arbitrary. Three design principles follow. We follow these principles and make a minimal redesign of SAX called TT-SAX (two-track SAX). The level letters stay. Each segment gains a trend letter. It is measured across neighboring segments rather than inside one, and graded to match the adjectives that queries use. We conduct extensive experiments on the public NLQTSBench benchmark, comparing TT-SAX with the six classical symbolizations across six LLMs. TT-SAX outperforms all six on shape queries, and ablations trace its gains back to the three limitations one by one. This paper is the first systematic study of time series symbolization with natural language querying as the design goal. It provides a foundation for future research on this task. Our code is available at https://github.com/Atlamtiz/tt-sax.

cs.DB↗

Resilience for Regular Path Queries: Towards a Complexity Classification

The resilience problem for a query and an input set or bag database is to compute the minimum number of facts to remove from the database to make the query false. In this paper, we study how to compute the resilience of Regular Path Queries (RPQs) over graph databases. Our goal is to characterize the regular languages L for which it is tractable to compute the resilience of the existentially-quantified RPQ built from L. We show that computing the resilience in this sense is tractable (even in combined complexity) for all RPQs defined from so-called local languages. By contrast, we show hardness in data complexity for RPQs defined from the following language classes (after reducing the languages to eliminate redundant words): all finite languages featuring a word containing a repeated letter, and all languages featuring a specific kind of counterexample to being local (which we call four-legged languages). The latter include in particular all languages that are not star-free. Our results also imply a dichotomy on all languages with a so-called neutral letter. We last show tractability for some classes of non-local languages, namely the so-called bipartite chain languages and one-dangling languages, and highlight some remaining obstacles towards a full dichotomy.

cs.DB↗