E xe SQL : Self-Taught Text-to- SQL Models with Execution-Driven Bootstrapping for SQL Dialects (2025)

Abstract: Recent text-to-SQL models have achieved strong performance, but their effectiveness remains largely confined to SQLite due to dataset limitations. However, real-world applications require SQL generation across multiple dialects with varying syntax and specialized features, which remains a challenge for current models. The main obstacle in building a dialect-aware model lies in acquiring high-quality dialect-specific data. Data generated purely through static prompting—without validating SQLs via execution—tends to be noisy and unreliable. Moreover, the lack of real execution environments in the training loop prevents models from grounding their predictions in executable semantics, limiting generalization despite surface-level improvements from data filtering. This work introduces ExeSQL, a text-to-SQL framework with execution-driven, agentic bootstrapping. The method consists of iterative query generation, execution-based filtering (e.g., rejection sampling), and preference-based training, enabling the model to adapt to new SQL dialects through verifiable, feedback-guided learning. Experiments show that ExeSQL bridges the dialect gap in text-to-SQL, achieving average improvements of 15.2%, 10.38%, and 4.49% over GPT-4o on PostgreSQL, MySQL, and Oracle, respectively, across multiple datasets of varying difficulty.

## introduction with the rapid advancement of large language models (llms), their capabilities in assisting with various coding tasks have significantly improved. tools like github copilot @xcite and models such as openai codex @xcite have enhanced developer productivity by automating repetitive tasks, providing real-time suggestions, and offering de-figure 1 : given a natural language question, different sql dialects require distinct syntax adjustments, such as explicit type casting in postgresql. beyond the traditional text-input-sql-output formulation, we incorporate the database environment to enable agentic execution feedback for data synthesis and training. rule-based translation is insufficient. rulebased translation offers a deterministic but rigid solution to sql dialect conversion. while transpilers like sqlglot @xcite provide structured mappings between dialects, they struggle with complex syntax, schema constraints, and dialect-specific functions @xcite . moreover, these systems lack generalizability, require dialect-specific rules @xcite , and cannot guarantee accurate translation. in practice, they still rely on execution-time feedback to detect and fix failures. maintaining such rule sets is costly and brittle. even with carefully crafted rules, such systems cannot guarantee perfect accuracy-particularly for complex or edge-case queries-and often rely on executiontime feedback for correction. we provide a detailed analysis in the appendix a.10. ## methodology in this section, we present the details of our approach to obtain exesql, including 3 phases: translation bootstrapping, iterative data generation and training, and preference enhancement. the key idea of execution-assisted generation is fully leveraging execution verification signals to asisst llm to generate high-quality data for textto-sql across different dialects. an illustration of exesql is shown in figure 3 . ## implementation and evaluation settings the bootstrap dataset and new questions for ex-esql are generated using gpt-4o (openai, 2023). we choose gpt-4o due to its superior ability to follow instructions and leverage error messages to generate accurate bootstrap dialect sql examples. the final exesql dataset consists of 20.6k samples in the supervised finetuning (sft) set and 8k samples in the preference pairs (appendix a.2). all training is conducted on four a6000 gpus. we fine-tune the full-parameter deepseek-coder-7b (guo et al., 2024) for supervised finetuning (sft) and direct preference optimization (dpo). for detailed training configurations and inference hyperparameters, please refer to appendix a.3 for baseline comparisons, we evaluate gpt-4o-2024-11-20 and gemini-1.5-pro-0827 @xcite , both of which were released in 2024. since these models were trained on publicly available data up to their release dates, they likely include extensive sql-related training data, ensuring a fair comparison. ## conclusion we propose an execution-driven framework to enhance text-to-sql generation across multiple sql dialects. by integrating llm-based dialect bootstrapping, execution feedback rejection sampling, and preference learning, our approach iteratively refines sql generation through execution validation and error correction. experiments show that exesql outperforms gpt-4o by a large margin on 2 dialects, respectively, demonstrating superior adaptability and correctness. our findings highlight the importance of execution-aware training and provide a scalable solution for robust multidialect text-to-sql modeling.