OmniSQL: Synthesizing High-quality Text-to-SQL Data at Scale

Haoyang Li, Shang Wu, Xiaokang Zhang, Xinmei Huang, Jing Zhang, Fuxin Jiang, Shuai Wang, Tieying Zhang, Jianjun Chen, Rui Shi, Hong Chen, Cuiping Li

TL;DR

OmniSQL introduces a highly scalable, automatic data synthesis framework that generates SynSQL-2.5M, the first million-scale text-to-SQL dataset complete with Chain-of-Thought (CoT) reasoning paths. By training open-source models (ranging from 7B to 32B parameters) on this massive, diverse dataset, the authors create OmniSQL, a model family that matches or outperforms closed-source giants like GPT-4o and DeepSeek-V3 on complex, domain-specific database tasks.

What Problem Does This Paper Address?

Translating natural language questions into executable SQL queries (Text-to-SQL) is essential for democratizing data access. Currently, practitioners face a frustrating trade-off:

  1. Prompting-based methods rely on massive, closed-source LLMs via APIs. This approach is expensive, introduces severe data privacy risks for enterprise data, and lacks customization.
  2. Fine-tuning-based methods use smaller, open-source models but suffer from poor generalizability. Because human-annotated datasets like Spider and BIRD are relatively small and narrow, fine-tuned models frequently fail when confronted with real-world, out-of-domain databases.

The bottleneck is data. Human annotation for complex relational databases is notoriously difficult and expensive to scale. This paper introduces an automated pipeline to synthesize high-quality, diverse text-to-SQL data at a million-sample scale without human intervention.

Methods

The authors propose a progressive, four-step data synthesis pipeline that decouples the generation process into manageable tasks handled entirely by open-source LLMs:

Figure 1: Illustration of the proposed text-to-SQL data synthesis framework.
  1. Web Table-Driven Database Synthesis: The pipeline bootstraps from millions of publicly available web tables (using the TabLib corpus). An LLM infers a business scenario from a table and expands it into a fully fleshed-out relational database schema (complete with primary/foreign keys and metadata). A subsequent database enhancement step injects extra columns to ensure real-world complexity.
  2. Complexity-Aware SQL Query Generation: To prevent the model from generating only trivial queries, the framework explicitly samples across four complexity levels (simple to highly complex) and uses a geometric distribution to constrain column selection, mimicking real-world data analysis needs.
  3. Stylized NL Question Synthesis: Instead of translating SQL straight back to standard text, the pipeline forces the LLM to adopt one of nine distinct linguistic styles (e.g., colloquial, vague, metaphorical, conversational). A semantic consistency selector filters out inaccurate translations by measuring embedding similarities.
  4. Chain-of-Thought (CoT) Solution Synthesis: For every sample, the pipeline generates a step-by-step reasoning path explaining how to get from the question to the SQL query. To ensure correctness, the framework generates multiple candidate CoT paths and uses a majority vote based on the execution results of the final SQL queries.

Datasets

The primary contribution is SynSQL-2.5M, containing 2,544,390 text-to-SQL pairs spanning 16,583 distinct synthetic databases.

Table 1: Overall statistics of different datasets. Note: † denotes that each database in WikiSQL consists of a single table. ∗ indicates that the number of unique SQL queries for BIRD cannot be calculated due to the inaccessibility of its test set.

To evaluate the models trained on SynSQL-2.5M, the authors test across nine distinct benchmarks:

  • Standard Benchmarks: Spider (dev/test) and BIRD (dev).
  • Domain-Specific Benchmarks: Spider2.0-SQLite, ScienceBenchmark, and EHRSQL (medical domain).
  • Robustness Benchmarks: Spider-DK, Spider-Syn, and Spider-Realistic.

Key Insights and Ideas

  • Web Tables as a Schema Goldmine: LLMs are surprisingly proficient at generating database schemas because their pre-training data is saturated with CREATE TABLE statements. Web tables provide the perfect semantic "seed" to scale domain diversity.
  • CoT as a Self-Correction Mechanism: During the final step of data synthesis, the authors discovered that generating a step-by-step reasoning path actually helps the LLM identify and fix minor bugs (like incorrect join paths) present in the initially generated SQL queries. In a GPT-4o evaluation of discrepant cases, the CoT-refined SQL was preferred 93.98% of the time.
  • Linguistic Diversity Drives Robustness: Real users rarely ask questions with perfect database terminology. By intentionally synthesizing vague, conversational, or metaphorical questions, the dataset prepares the model for messy, real-world deployments.

Key Results

The resulting model, OmniSQL, achieves state-of-the-art performance across the board, frequently beating models many times its size:

  • Standard Benchmarks: OmniSQL-7B achieved 87.9% execution accuracy on the Spider test set using greedy decoding, outperforming the top public API-based method on the leaderboard (DAIL-SQL + GPT-4 at 86.6%). OmniSQL-32B achieved 67.0% on BIRD dev, matching specialized GPT-4o fine-tuned pipelines.
  • Domain Generalization: On EHRSQL (a highly specialized medical database benchmark), OmniSQL-32B scored 46.8%, outperforming zero-shot GPT-4o by 1.3%, despite never seeing EHRSQL data during training.
  • Quality Metrics: When evaluated by GPT-4o across multiple data-quality dimensions, SynSQL-2.5M consistently scored higher than the human-annotated BIRD dataset in areas like schema complexity, field definition, and SQL correctness.
Quality evaluation of SynSQL-2.5M and BIRD judged by GPT-4o.

Limitations and Future Work

  • The Commonsense Gap: OmniSQL underperformed slightly on Spider-DK, a benchmark specifically designed to test implicit, real-world commonsense knowledge (e.g., knowing that "highly rated" implies looking at a review score column). The authors suggest adding a specific "commonsense" linguistic style to the data synthesis pipeline to mitigate this.
  • Single-Step vs. Multi-Agent: OmniSQL was evaluated as a single-turn, single-step model. The authors note that its performance could be amplified even further if integrated into multi-stage agentic frameworks that handle explicit schema linking and iterative SQL refinement.

Summary updated

BibTeX
@article{li2025omnisql,
  author = {Haoyang Li and Shang Wu and Xiaokang Zhang and Xinmei Huang and Jing Zhang and Fuxin Jiang and Shuai Wang and Tieying Zhang and Jianjun Chen and Rui Shi and Hong Chen and Cuiping Li},
  title = {{OmniSQL: Synthesizing High-quality Text-to-SQL Data at Scale}},
  journal = {Proc. VLDB Endow.},
  year = {2025},
  doi = {10.14778/3749646.3749723},
}
Figure