Lune

SIGMOD2025Top-tier venue

Cracking SQL Barriers: An LLM-based Dialect Translation System

Wei Zhou, Yuyang Gao, Xuanhe Zhou, Guoliang Li

Abstract

Automatic dialect translation reduces the complexity of database migration, which is crucial for applications interacting with multiple database systems. However, rule-based translation tools (e.g., SQLGlot, jOOQ, SQLines) are labor-intensive to develop and often (1) fail to translate certain operations, (2) produce incorrect translations due to rule deficiencies, and (3) generate translations compatible with some database versions but not the others.

In this paper, we investigate the problem of automating dialect translation with large language models (LLMs). There are three main challenges. First, queries often involve lengthy content (e.g., excessive column values) and multiple syntax elements that require translation, increasing the risk of LLM hallucination. Second, database dialects have diverse syntax trees and specifications, making it difficult for cross-dialect syntax matching. Third, dialect translation often involves complex many-to-one relationships between source and target operations, making it impractical to translate each operation in isolation. To address these challenges, we propose an automatic dialect translation system CrackSQL. First, we propose Functionality-based Query Processing that segments the query by functionality syntax trees and simplifies the query via (𝑖) customized function normalization and (𝑖𝑖) translation-irrelevant query abstraction. Second, we design a Cross-Dialect Syntax Embedding Model to generate embeddings by the syntax trees and specifications (of certain version), enabling accurate query syntax matching. Third, we propose a Local-to-Global Dialect Translation strategy, which restricts LLM-based translation and validation on operations that cause local failures, iteratively extending these operations until translation succeeds. Experiments show CrackSQL significantly outperforms existing methods (e.g., by up to 77.42%). The code is available at https:// github.com/ weAIDB/ CrackSQL.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

5 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Dial: A Knowledge-Grounded Dialect-Specific NL2SQL System cites DBAIOps: A Reasoning LLM-Enhanced Database Operation and Maintenance System using Knowledge Graphs
  • Dial: A Knowledge-Grounded Dialect-Specific NL2SQL System cites Automating Database-Native Function Code Synthesis with LLMs
  • D-Bot: Database Diagnosis System using Large Language Models cites WeTune: Automatic Discovery and Verification of Query Rewrite Rules
  • LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiency cites A Learned Query Rewrite System using Monte Carlo Tree Search
  • LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query Efficiency cites WeTune: Automatic Discovery and Verification of Query Rewrite Rules
  • Automating Database-Native Function Code Synthesis with LLMs cites DBAIOps: A Reasoning LLM-Enhanced Database Operation and Maintenance System using Knowledge Graphs
  • WeTune: Automatic Discovery and Verification of Query Rewrite Rules cites A Learned Query Rewrite System using Monte Carlo Tree Search
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers5

  1. DBAIOps: A Reasoning LLM-Enhanced Database Operation and Maintenance System using Knowledge GraphsWei Zhou, Peng Sun, Xuanhe Zhou, Qianglei Zang et al.VLDB 2026 · 9 citations
  2. Automating Database-Native Function Code Synthesis with LLMsWei Zhou, Xuanhe Zhou, Qikang He, Guoliang Li et al.SIGMOD 2026 · 6 citations
  3. Dial: A Knowledge-Grounded Dialect-Specific NL2SQL SystemXiang Zhang, Le Zhou, Hongming Xu, Wei Zhou et al.VLDB 2026 · 2 citations
  4. AGRAG: Advanced Graph-Based Retrieval-Augmented Generation for LLMsYubo Wang, Haoyang Li, Fei Teng, Lei ChenICDE 2026
  5. RISE: Rule-Driven SQL Dialect Translation via Query ReductionXudong Xie, Yuwei Zhang, Wensheng Dou, Yu Gao et al.ICSE 2026

Builds on8

  1. A Learned Query Rewrite System using Monte Carlo Tree SearchXuanhe Zhou, Guoliang Li, Chengliang Chai, Jianhua FengVLDB 2022 · 85 citations
  2. GPTuner: A Manual-Reading Database Tuning System via GPT-Guided Bayesian OptimizationJiale Lao, Yibo Wang, Yufei Li, Jianping Wang et al.VLDB 2024 · 76 citations
  3. LLM-R2: A Large Language Model Enhanced Rule-based Rewrite System for Boosting Query EfficiencyZhaodonghui Li, Haitao Yuan, Huiming Wang, Gao Cong et al.VLDB 2025 · 52 citations
  4. D-Bot: Database Diagnosis System using Large Language ModelsXuanhe Zhou, Guoliang Li, Zhaoyan Sun, Zhiyuan Liu et al.VLDB 2024 · 50 citations
  5. WeTune: Automatic Discovery and Verification of Query Rewrite RulesZhaoguo Wang, Zhou Zhou, Yicun Yang, Haoran Ding et al.SIGMOD 2022 · 35 citations

Related papers

  1. DLBench: A Comprehensive Benchmark for SQL Translation with Large Language ModelsLi Lin, Hongqiao Chen, Qinglin Zhu, Liehang Chen et al.ASE 2025
  2. Dialect-SQL: An Adaptive Framework for Bridging the Dialect Gap in Text-to-SQLJie Shi, Xi Cao, Bo Xu, Jiaqing Liang et al.EMNLP 2025 · 2 citations
  3. Dialect-Agnostic SQL Parsing via LLM-Based SegmentationJunwen An, Kabilan Mahathevan, Manuel RiggerSIGMOD 2026
  4. DAC: Decomposed Automation Correction for Text-to-SQLDingzirui Wang, Longxu Dou, Xuanliang Zhang, Qingfu Zhu et al.EMNLP Findings 2025 · 5 citations
  5. LLMSQLMUTATOR: LLM-Powered Test Case Generation for Database Using Bug ReportsChenglin Tian, Chaofan Li, Yawen Li, Yingxia ShaoICDE 2026
Dusk over the sea between two cliffs drawn in fine vertical lines