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 both in-context prompting with mapped queries and fine-tuning on mapped data consistently yield higher text-to-SQL performance than using examples drawn directly from the source schema.
翻译:本文提出SQL-Exchange框架,该框架通过保持源查询结构、同时将领域特定元素适配至目标模式,实现不同数据库模式间SQL查询的映射。我们探究了此类映射的可行性条件与实际效益,并分析了其作为下游任务对文本到SQL系统上下文学习性能的提升作用。通过在多个模型系列与基准数据集上进行综合评估——涵盖与源查询的结构对齐性、目标数据库上的执行有效性及语义正确性——实验表明SQL-Exchange在广泛的数据模式与查询类型中均表现有效。结果进一步显示,无论是使用映射查询进行上下文提示,还是基于映射数据进行微调,其文本到SQL性能均持续优于直接采用源模式示例的方法。