SQL-Exchange: Transforming SQL Queries Across Domains

📅 2025-08-09
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the challenges of SQL query migration across heterogeneous database schemas and the limited effectiveness of in-context learning in cross-database text-to-SQL tasks. To this end, we propose SQL-Exchange, the first framework to systematically explore and validate the feasibility and efficacy of structure-preserving cross-schema SQL query mapping. Our method leverages a structural alignment mechanism that jointly incorporates schema syntactic matching and semantic consistency constraints, enabling faithful preservation of the source query’s structural skeleton while adaptively rewriting domain-specific elements (e.g., table names, column names, value domains) to conform to the target schema. Extensive experiments across multiple LLM families (e.g., LLaMA, Qwen) and standard text-to-SQL benchmarks (Spider, BIRD) demonstrate that context examples generated via our mapping significantly improve zero-shot and few-shot text-to-SQL accuracy—achieving an average gain of 12.7%. Moreover, SQL-Exchange exhibits strong robustness on complex nested queries and cross-domain schema migrations.

Technology Category

Application Category

📝 Abstract
We introduce SQL-Exchange, a framework for mapping SQL queries across different database schemas by preserving the source query structure while adapting domain-specific elements to align with the target schema. We investigate the conditions under which such mappings are feasible and beneficial, and examine their impact on enhancing the in-context learning performance of text-to-SQL systems as a downstream task. Our comprehensive evaluation across multiple model families and benchmark datasets--assessing structural alignment with source queries, execution validity on target databases, and semantic correctness--demonstrates that SQL-Exchange is effective across a wide range of schemas and query types. Our results further show that using mapped queries as in-context examples consistently improves text-to-SQL performance over using queries from the source schema.
Problem

Research questions and friction points this paper is trying to address.

Mapping SQL queries across different database schemas
Enhancing in-context learning for text-to-SQL systems
Evaluating structural alignment and execution validity
Innovation

Methods, ideas, or system contributions that make the work stand out.

Maps SQL queries across different database schemas
Preserves source query structure, adapts domain elements
Improves text-to-SQL performance with mapped queries
🔎 Similar Papers