MultiSQL: A Schema-Integrated Context-Dependent Text2SQL Dataset with Diverse SQL Operations

Chunhui Li, Yifan Wang, Zhen Wu, Zhen Yu, Fei Zhao, Shujian Huang, Xinyu Dai

Abstract

MultiSQL is a novel dataset designed to advance Text2SQL research by incorporating schema-integrated, context-dependent interactions. Unlike traditional benchmarks focused solely on data retrieval, MultiSQL includes diverse operations such as CREATE, UPDATE, and ALTER, simulating real-world database management across long-form dialogues. It challenges models to track how a database's structure and content evolve over nearly 12 turns per interaction.

Introduction

In Natural Language Processing, the Text2SQL task—converting natural language into SQL queries—is a cornerstone of machine reasoning. However, existing benchmarks often treat databases as static entities to be searched rather than dynamic systems to be managed. Researchers from Nanjing University and Tencent have introduced MultiSQL to bridge the gap between simple retrieval and realistic, interactive database management.

Addressing the Operation Monoculture

Most Text2SQL research relies on datasets like Spider or CoSQL, which primarily focus on SELECT statements. MultiSQL addresses three critical limitations of these benchmarks:

  1. Operation Diversity: Real-world users need to modify structures and data, not just query them. MultiSQL includes INSERT, UPDATE, CREATE, and ALTER operations.
  2. Dynamic Schemas: Models must track schema changes (e.g., adding a column) mid-conversation and use those changes in subsequent queries.
  3. Dialogue Length: MultiSQL extends interactions to an average of 11.82 turns, compared to the ~3-turn average in existing datasets, simulating the complexity of long-form human-database interaction.
Example of a multi-turn dialogue in MultiSQL involving schema modification (ALTER), data updates (UPDATE), and retrieval (SELECT).

The MultiSQL Dataset

The MultiSQL dataset comprises 783 dialogue groups with 9,257 interaction turns across 166 different databases. A key feature is its operational diversity, which moves beyond the "SELECT-only" paradigm prevalent in earlier research.

Distribution of SQL operations in the MultiSQL dataset, showing a balanced mix of SELECT, INSERT, UPDATE, CREATE, and ALTER statements.

Methodology: Generation and Refinement

The authors utilized a hybrid approach to construct the dataset:

  • Structured Prompting: GPT-4 generated initial dialogues using "System Info," "Table Schema," and "Chain of Thought" instructions to ensure logical SQL formulation.
  • Manual Oversight: The team spent 114 person-hours manually correcting grammar, semantic misalignments, and improving contextual relevance.
  • Self-Refinement Framework: An evaluation-phase framework allows models to test their generated SQL against an executor and self-correct based on error feedback.

Key Insights and Evaluation

The core innovation is Schema-Integrated Context, where the model tracks the evolving state of the database as part of the dialogue history. To evaluate this accurately, the authors proposed new metrics:

  • Context-aware Match: Uses fuzzy matching to handle naming variations in structural changes like CREATE and ALTER statements.
  • Database State Match: Compares the final state of the database after execution rather than just checking the SQL syntax. If the resulting data and structure are identical to the ground truth, the model passes.

Results and Conclusion

Evaluation of various models revealed that GPT-4 remains the gold standard, particularly when paired with self-refinement strategies, achieving 70.1% execution accuracy on SELECT statements. Conversely, open-source models like LLaMA2-7B struggled significantly with complex state-matching tasks. While MultiSQL represents a significant step forward, future work will focus on handling the "noise" of production environments—such as ambiguous column names and missing values—and optimizing query efficiency.

Summary updated

BibTeX
@inproceedings{li2024multisql,
  author = {Chunhui Li and Yifan Wang and Zhen Wu and Zhen Yu and Fei Zhao and Shujian Huang and Xinyu Dai},
  title = {{MultiSQL: A Schema-Integrated Context-Dependent Text2SQL Dataset with Diverse SQL Operations}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2024},
  doi = {10.18653/v1/2024.findings-acl.823},
}
Figure