Translating SQL dialects across different relational database management systems (RDBMSs) is crucial for migrating RDBMS-based applications to the cloud. Traditional SQL dialect translation tools rely on manually-crafted rules, necessitating significant manual effort to support new RDBMSs and dialects. Although large language models (LLMs) can assist in translating SQL dialects, they often struggle with lengthy and complex SQL queries. In this paper, we propose RISE, a novel LLM-based SQL dialect translation approach that can accurately handle lengthy and complex SQL queries. Given a complex source query $Q_c$ that contains a SQL dialect $d$, we first employ a dialect-aware query reduction technique to derive a simplified query $Q_{s}$ by removing $d$-irrelevant SQL elements from $Q_c$. Subsequently, we utilize LLMs to translate $Q_{s}$ into $Q_{s^{'}}$, and automatically extract the translation rule $r_d$ for dialect $d$ based on the relationship between $Q_{s}$ and $Q_{s^{'}}$. By applying $r_d$ to $Q_c$, we can effectively translate the dialect $d$ within $Q_c$, thereby bypassing the complexity of the source query $Q_c$. We evaluate RISE on two real-world benchmarks, i.e., TPC-DS and SQLProcBench, comparing its performance against both the traditional rule-based tools and the LLM-based approaches with respect to translation accuracy. RISE achieves accuracies of 97.98% on TPC-DS and 100% on SQLProcBench, outperforming the baselines by an average improvement of 24.62% and 238.41%, respectively.


翻译:在不同关系数据库管理系统(RDBMS)之间进行SQL方言翻译,对于将基于RDBMS的应用程序迁移至云端至关重要。传统的SQL方言翻译工具依赖于人工编写的规则,需要大量手动工作以支持新的RDBMS和方言。尽管大型语言模型(LLMs)能够辅助SQL方言翻译,但其在处理冗长且复杂的SQL查询时往往表现不佳。本文提出RISE,一种新颖的基于LLM的SQL方言翻译方法,能够准确处理冗长复杂的SQL查询。给定一个包含SQL方言$d$的复杂源查询$Q_c$,我们首先采用方言感知的查询简化技术,通过从$Q_c$中移除与$d$无关的SQL元素,推导出简化查询$Q_{s}$。随后,我们利用LLMs将$Q_{s}$翻译为$Q_{s^{'}}$,并根据$Q_{s}$与$Q_{s^{'}}$之间的关系自动提取针对方言$d$的翻译规则$r_d$。通过将$r_d$应用于$Q_c$,我们能够有效翻译$Q_c$中的方言$d$,从而规避源查询$Q_c$的复杂性。我们在两个真实世界基准测试(即TPC-DS和SQLProcBench)上评估RISE,从翻译准确性的角度将其性能与传统基于规则的工具及基于LLM的方法进行比较。RISE在TPC-DS上达到97.98%的准确率,在SQLProcBench上达到100%的准确率,分别以平均24.62%和238.41%的幅度超越基线方法。

0
下载
关闭预览

相关内容

SQL 全名是结构化查询语言,是用于数据库中的标准数据查询语言,IBM 公司最早使用在其开发的数据库系统中。
【AAAI2024】LAMM: 多模态提示学习的标签对齐
专知会员服务
41+阅读 · 2023年12月14日
Shreya Gherani:BERT庖丁解牛(Neo Yan翻译)
CreateAMind
10+阅读 · 2019年8月10日
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
18+阅读 · 2017年12月31日
国家自然科学基金
2+阅读 · 2016年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员