Dialect-SQL: An Adaptive Framework for Bridging the Dialect Gap in Text-to-SQL

Jie Shi, Xi Cao, Bo Xu, Jiaqing Liang, Yanghua Xiao, Jia Chen, Peng Wang, Wei Wang


Abstract
Text-to-SQL is the task of translating natural language questions into SQL queries based on relational databases. Different databases implement their own SQL dialects, leading to variations in syntax. As a result, SQL queries designed for one database may not execute properly in another, creating a dialect gap. Existing Text-to-SQL research primarily focuses on specific database systems, limiting adaptability to different dialects. This paper proposes a novel adaptive framework called Dialect-SQL, which employs Object Relational Mapping (ORM) code as an intermediate language to bridge this gap. Given a question, we guide Large Language Models (LLMs) to first generate ORM code, which is then parsed into SQL queries targeted for specific databases. However, there is a lack of high-quality Text-to-Code datasets that enable LLMs to effectively generate ORM code. To address this issue, we propose a bootstrapping approach to synthesize ORM code, where verified ORM code is iteratively integrated into a demonstration pool that serves as in-context examples for ORM code generation. Our experiments demonstrate that Dialect-SQL significantly enhances dialect adaptability, outperforming traditional methods that generate SQL queries directly. Our code and data are released at https://github.com/jieshi10/orm-sql.
Anthology ID:
2025.emnlp-main.178
Volume:
Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing
Month:
November
Year:
2025
Address:
Suzhou, China
Editors:
Christos Christodoulopoulos, Tanmoy Chakraborty, Carolyn Rose, Violet Peng
Venue:
EMNLP
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
3604–3619
Language:
URL:
https://preview.aclanthology.org/corrections-2025-11/2025.emnlp-main.178/
DOI:
10.18653/v1/2025.emnlp-main.178
Bibkey:
Cite (ACL):
Jie Shi, Xi Cao, Bo Xu, Jiaqing Liang, Yanghua Xiao, Jia Chen, Peng Wang, and Wei Wang. 2025. Dialect-SQL: An Adaptive Framework for Bridging the Dialect Gap in Text-to-SQL. In Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing, pages 3604–3619, Suzhou, China. Association for Computational Linguistics.
Cite (Informal):
Dialect-SQL: An Adaptive Framework for Bridging the Dialect Gap in Text-to-SQL (Shi et al., EMNLP 2025)
Copy Citation:
PDF:
https://preview.aclanthology.org/corrections-2025-11/2025.emnlp-main.178.pdf
Checklist:
 2025.emnlp-main.178.checklist.pdf