Skip to content

SQL2SQLBench: A Benchmark for Database Dialect Translation

Yuyang Gao, Zhaoyan Sun, Guoliang Li

cs.DB

Abstract

SQL dialect translation refers to converting a SQL query from one dialect to its equivalent in another dialect. Automating this process is crucial for streamlining database migrations and ensuring cross-system compatibility. Although there are many rule-based and LLM-based dialect translators, the field lacks comprehensive benchmarks to evaluate their effectiveness across diverse real-world scenarios. To address this problem, we propose SQL2SQLBench, a comprehensive benchmark for database dialect translation. First, we generate a comprehensive dataset with broad coverage in schemas, data values, and diverse dialects, grounded in real-world sources. Second, we propose Translation Point Definition Language (TPDL) to break down translation behaviors into a sequence of translation points (i.e., atomic translation of individual SQL syntactic segments across dialects). Using TPDL, we generate a comprehensive set of SQL translation pairs with fine-grained coverage of translation points, mimicking real-world queries. Third, to evaluate whether SQL dialect translators can correctly translate a source query from one dialect to a target query in another dialect, we design a progressive translation equivalence verification pipeline that combines execution-based verification with dialect-adapted formal verification. Finally, we evaluate state-of-the-art dialect translators using our open-sourced testbed and provide detailed insights.

Create a lesson

Metadata

Comments
12 pages, 6 figures, 10 tables. Code and benchmark are available at https://github.com/TsinghuaDatabaseGroup/SQL2SQLBench