CrackSQL : A Hybrid SQL Dialect Translation System Powered by Large Language Models
Wei Zhou, Yuyang Gao, Xuanhe Zhou, Guoliang Li · 2025
Read CrackSQL : A Hybrid SQL Dialect Translation System Powered by Large Language Models by Wei Zhou, Yuyang Gao, Xuanhe Zhou, Guoliang Li (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2504-00882.txt.
Introduction
Translating SQL between database dialects is automated by CrackSQL, presented by Wei Zhou and co-authors in a 2025 demonstration paper. Dialect translation enables smooth work across heterogeneous database systems. Queries differ across dialects in syntax and in subtle semantics, so moving a query from one system to another is a hard task that often needs manual rewriting.
Rule systems need costly upkeep, and language models alone can invent functions that do not exist. CrackSQL is a hybrid that joins rule and model methods. It segments long, complex queries by functionality, which lifts accuracy. A cross-dialect syntax embedding model aligns syntax precisely, and an adaptive local-to-global step joins the parts. The system aims for robust translation with less manual effort.
Catalog record
| CREATOR | Wei Zhou, Yuyang Gao, Xuanhe Zhou, Guoliang Li |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 20 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2504-00882
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
CrackSQL : A Hybrid SQL Dialect Translation System Powered by Large Language Models Wei Zhou, Yuyang Gao, Xuanhe Zhou, Guoliang Li Abstract . Dialect translation plays a key role in enabling seamless interaction across heterogeneous database systems. However, translating SQL queries between different dialects (e.g., from PostgreSQL to MySQL) remains a challenging task due to syntactic discrepancies and subtle semantic variations. Existing approaches including manual rewriting, rule-based systems, and large language model ( LLM )-based techniques often involve high maintenance effort (e.g., crafting custom translation rules) or produce unreliable results (e.g., LLM generates non-existent functions), especially when handling complex queries. In this demonstration, we present CrackSQL , the first hybrid SQL dialect translation system that combines rule and LLM-based methods to overcome these limitations. CrackSQL leverages the adaptability of LLMs to minimize manual intervention, while enhancing translation accuracy by segmenting lengthy complex SQL via functionality-based query processing. To further improve robustness, it incorporates a novel cross-dialect syntax embedding model for precise syntax alignment, as well as an adaptive local-to-global translation strategy that effectively resolves interdependent query operations. CrackSQL supports three translation modes and offers multiple deployment and access options including a web console interface, a PyPI package, and a command-line prompt, facilitating adoption across a variety of real-world use cases 1 1 1 The demonstration video is available at: https://vimeo.com/1071435762?share=copy . . † † authors: . PVLDB Reference Format: PVLDB, 14(1): XXX-XXX, 2020. doi:XX.XX/XXX.XX † † This work is licensed under the Creative Commons BY-NC-ND 4.0 International License. Visit https://creativecommons.org/licenses/by-nc-nd/4.0/ to view a copy of this license. For any use beyond those covered by this license, obtain permission by emailing [email protected] . Copyright is held by the owner/author(s). Publication rights licensed to the VLDB Endowment. Proceedings of the VLDB Endowment, Vol. 14, No. 1 ISSN 2150-8097. doi:XX.XX/XXX.XX PVLDB Artifact Availability: The source code, data, and/or other artifacts have been made available at https://github.com/weAIDB/CrackSQL . 1. Introduction Dialect translation aims to convert a SQL query written for one database system (e.g., PostgreSQL) into a functionally equivalent query that can be executed on another system (e.g., MySQL). This capability is essential for simplifying database migration and supports various applications such as NL2SQL ( Kim et al. 2020 ) , extract-transform-load (ETL) processes ( Babu and Gunasingh 2016 ) , and cross-database analytics tools ( Gavriilidis et al. 2023 ) , enabling smooth interaction across different database systems. Table 1. Comparison of Dialect Translation Methods. Method #Dialect Feedback Instruction Translation Overhead New Dialect Support Human 1-3 Dialects of Expertise ✓ Minutes Manual SQLGlot 24 Common Dialects \times Seconds Manual LLM LLM Compatible \times Seconds to Minutes Automatic CrackSQL 24 + LLM Compatible \checkmark Seconds to Minutes Automatic As summarized in Table 1 , existing dialect translation approaches can be classified into three categories: (1) Manual translation that entirely relies on human expertise across different database dialects for query analysis and rewriting; (2) Rule-based methods (e.g., SQLGlot ( sql [n.d.]a ) ) that employ handcrafted translation rules but require extensive custom code for specific cases, resulting in significant maintenance overhead; and (3) LLM-based techniques ( Ngom and Kraska 2024 ) that leverage LLM for either direct query translation or rule generation, representing an initial step toward automation. While each approach offers distinct advantages, they all exhibit notable limitations that hinder their effectiveness in practice. (Limitation 1) High Manual Effort for Code Maintenance. Existing tools (e.g., SQLGlot ( sql [n.d.]a ) , jOOQ ( jq [n.d.] ) , SQLines ( sql [n.d.]b ) ) depend on significant manual work by developers to identify equivalent syntax patterns and define corresponding translation rules for different SQL dialects. In addition, maintaining these tools can be challenging, as they often require continuous updates to address translation issues and ensure accuracy. For instance, more than 2,000 unresolved issues remain open in the jOOQ code repository ( jq [n.d.] ) , and SQLGlot involves active development with contributions from over 200 developers on GitHub ( sql [n.d.]a ) . (Limitation 2) Hallucination Issues in Deterministic Translation. Although LLM demonstrates strong reasoning and coding capabilities that enable it to support new SQL dialects automatically, we observe that hallucination remains a significant issue, particularly with long and complex real-world SQL queries. In such cases, LLM may incorrectly translate queries into operations that are not equivalent or introduce functions that do not exist in the target dialect, often due to limited understanding of dialect-specific features. In addition, it does not make use of valuable external feedback, such as database error messages, to guide or improve the overall translation process. Figure 1. Architecture of CrackSQL . Our Methodology. To address the above limitations, we propose CrackSQL , the first dialect translation system that integrates both rule-based and LLM -based approaches. This demonstration is an extension of our research paper ( Zhou et al. 2025 ) . CrackSQL leverages the ability of LLM to support new SQL dialects automatically, thereby reducing the manual effort required to develop rule-based translation tools. It further improves translation effectiveness by decomposing the input SQL query into smaller functional operations (e.g., the CAST() function), which simplifies the translation process and helps mitigate hallucination issues in long and complex queries. In addition, CrackSQL makes the translation process more accurate and consistent through two key techniques: (1) A novel cross-dialect embedding model that matches equivalent syntax elements by considering both the code structure (e.g., the BNF tree) of the element and its textual specification, addressing the challenge of identifying equivalent elements across dialects; (2) An adaptive translation strategy that incrementally expands the current translation scope, from local-level snippets to broader SQL queries, capturing dependencies among different operations of the query. 2. CrackSQL Overview As illustrated in Figure 1 , CrackSQL comprises four modules to facilitate dialect translation. The system supports three distinct operational modes (Table 2 ), enabling flexible processing of user requests. By integrating rule-based methods with LLM , CrackSQL ensures robust cross-dialect interoperability while maintaining compatibility with conventional database operations. Table 2. Supported Translation Modes in CrackSQL . Mode #Dialect LLM (w/o & w fine-tuned) Embedding Model (w/o & w fine-tuned) Cloud Local Cloud Local Rule-only 24 \times \times \times \times LLM-direct ✓ ✓ ✓ \times \times Rule+LLM 3 (PG/MySQL/Oracle) ✓ ✓ ✓ ✓ Workflow. The translation process begins when the translation requests are submitted via the User Interface with three methods (i.e., the web console, the PyPI package 2 2 2 The PyPI package can be found at: https://pypi.org/project/cracksql/ . , and the command prompt). Then, these requests are routed to the unified Translation Server , which orchestrates the core translation logic via the SQLAlchemy engine (❶). The server dynamically configures translations based on user-specified parameters, with different operational modes requiring distinct services. For example, the Rule + LLM mode conducts translation in the following steps (the detailed technical design are presented in Section 3 ). It first undergoes functionality-based query processing to decompose the whole SQL into several snippets for ease of LLM translation over lengthy SQL. Then, it employs local-to-global translation strategy instructed by the Database Engine , which locates the prepared SQL snippets with execution errors (❷). During the translation process, it will iteratively turn to Computation Engine in multiple rounds with two basic operations (❸): (1)