NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

ExeSQL: Self-Taught Text-to-SQL Models with Execution-Driven Bootstrapping for SQL Dialects

Jipeng Zhang, Haolin Yang, Kehao Miao, Ruiyuan Zhang, Renjie Pi, Jiahui Gao, Xiaofang Zhou

TL;DR

This paper introduces ExeSQL, a novel framework that tackles the challenge of generating SQL queries for various database dialects beyond the common SQLite. By leveraging execution feedback to bootstrap and refine training data, ExeSQL significantly improves text-to-SQL performance across PostgreSQL, MySQL, and Oracle, outperforming even large language models like GPT-4o.

What Problem Does This Paper Address?

The vast majority of text-to-SQL research and datasets are focused on the SQLite dialect. However, real-world applications demand the ability to generate SQL for a multitude of database systems, each with its own unique syntax and features (e.g., PostgreSQL, MySQL, Oracle). The primary hurdle in building models that can handle these diverse dialects is the scarcity of high-quality, dialect-specific training data. Simply generating SQL using static prompts without verifying its execution often leads to noisy and unreliable data. Furthermore, current training methods often lack the grounding in actual execution environments, limiting the models' ability to understand and generate semantically correct SQL across different dialects.

Methods

ExeSQL employs an "agentic bootstrapping" approach, which can be broken down into three main stages:

  1. Translation Bootstrapping: To overcome the cold-start problem for new dialects, the authors leverage existing high-resource SQLite datasets. They use a large language model (LLM) to translate SQLite SQL queries into target dialects. This initial translation is then refined through an iterative process involving execution feedback.
  2. Iterative Data Generation and Training: This stage involves a loop where the model generates multiple SQL candidates for a given natural language question. These candidates are then executed against a real database.
  3. Execution-based Rejection Sampling: Queries that execute successfully are kept to augment the training dataset. Failed queries are used to provide error signals.
  4. Augmented Question Generation: To improve generalization, new natural language questions are generated, sometimes by leveraging actual database values to create contextually relevant queries.
  5. Preference Enhancement: To further refine the model, Direct Preference Optimization (DPO) is used. This involves creating preference pairs (correct vs. incorrect SQL queries) based on execution outcomes. The model is then trained to favor generating the correct, executable SQL.

Datasets

The paper utilizes existing datasets and generates new data:

  • Existing Datasets:
    • SQLite: Used as the source for bootstrapping translations.
  • Spider: A widely used benchmark for text-to-SQL, adapted for dialect-specific evaluation.
  • WikiSQL: Another popular text-to-SQL dataset, used for generating new questions and for evaluation.
  • Dr.Spider: An extension of Spider designed to test robustness against perturbations in databases, natural language queries, and SQL.
  • Bird: A challenging dataset for evaluating in-context learning capabilities with complex SQL queries.
  • MimicSQL: A single-domain dataset from electronic health records, used for evaluating generalization to specific domains.
  • New Data: The authors generate new dialect-specific questions and SQL pairs, contributing to the SFT and DPO training sets.

Key Insights and Ideas

  • Execution is King: The core idea is that validating SQL through actual execution is crucial for generating high-quality, dialect-aware training data. Static generation alone is insufficient.
  • Agentic Bootstrapping: The iterative, feedback-driven process of generating, executing, and refining SQL queries allows the model to learn from its mistakes and adapt to dialect-specific nuances without extensive manual annotation.
  • Dialect Gap is Real: Even powerful general-purpose LLMs struggle significantly when faced with SQL dialects beyond SQLite, highlighting the need for specialized training.
  • Data Quality Over Quantity: The DPO stage, using a relatively small amount of high-quality preference data derived from execution feedback, significantly boosts performance, underscoring the importance of data quality.

Key Results

ExeSQL demonstrates substantial improvements across multiple SQL dialects:

  • Cross-Dialect Performance: ExeSQL achieves an average accuracy of 66.70% across PostgreSQL, MySQL, and Oracle.
  • Outperforming Baselines: It significantly outperforms GPT-4o (average improvement of 15.2% on PostgreSQL, 10.38% on MySQL, and 4.49% on Oracle), Gemini-1.5-pro, and specialized code/SQL LLMs.
  • Robustness: ExeSQL shows strong generalization capabilities on both in-distribution and out-of-distribution datasets like Dr.Spider.
  • Efficiency: The iterative refinement process, while involving execution, is argued to be a one-time cost during data generation, leading to more accurate models for inference.

Limitations and Future Work

  • Limited Dialect Coverage: The current work primarily focuses on MySQL and PostgreSQL, with some evaluation on Oracle. The authors acknowledge that this setting overlooks complexities in larger-scale or heterogeneous scenarios and doesn't fully address advanced dialect-specific features (e.g., complex window functions, Regex handling).
  • Prompt Dependency: The iterative generation process relies on predefined prompts and partial rules, which might not accommodate databases with significantly different formal grammars.
  • Future Work: The authors plan to explore more dialects and more complex database conditions to enhance coverage and robustness. They also suggest investigating more sophisticated multi-dialect training strategies like in-batch mixing, data replay, or model merging to further improve cross-dialect generalization.

Summary updated

BibTeX
@inproceedings{zhang2025exesql,
  author = {Jipeng Zhang and Haolin Yang and Kehao Miao and Ruiyuan Zhang and Renjie Pi and Jiahui Gao and Xiaofang Zhou},
  title = {{ExeSQL: Self-Taught Text-to-SQL Models with Execution-Driven Bootstrapping for SQL Dialects}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
  url = {https://openreview.net/forum?id=e5aiWfaMex},
}
Figure