DS-NL2SQL
收藏资源简介:
DS-NL2SQL 是一个高质量、多方言的自然语言转SQL(NL2SQL)基准数据集,旨在评估特定方言的SQL生成能力。现有Text-to-SQL基准(如Spider和BIRD)主要关注SQLite兼容语法,而DS-NL2SQL填补了真实企业数据库方言的语法特异性和异质性空白。该数据集提供并行多方言的NL-SQL对,并强调具有严格语法约束、隐式跨子句依赖以及不同数据库引擎间函数签名变化的复杂查询。 关键特性包括: - **规模**:包含2,218个测试样本,覆盖796个不同的数据库。 - **支持的异构方言(6种)**:SQLite (v3.45.3)、MySQL (v8.0.45)、PostgreSQL (v14.20)、SQL Server (v17.0)、DuckDB (v1.4.3) 和 Oracle Database (19c)。 - **高方言差异性**:每个样本平均方言差异为3.67分(BIRD Mini-Dev为1.60),确保对引擎特定约束的严格评估。 - **方言不兼容性聚焦**:仅保留表现出方言排他性的查询(即由于方言不匹配至少在一个系统上失败的查询),排除通用跨系统查询(如简单的`SELECT * FROM table`)。 - **执行等价性保证**:所有并行SQL变体均经过精心验证(并在自动化工具失败时手动纠正),以确保在所有目标数据库引擎上的执行结果严格一致。 数据来源包括Spider、BIRD、SParC、CoSQL、OmniSQL和Archer等多个主流数据集。数据集以JSON格式提供,每个条目包含数据库ID、自然语言用户意图和各方言的黄金SQL。
DS-NL2SQL is a high-quality, multi-dialect natural language to SQL (NL2SQL) benchmark dataset designed to evaluate SQL generation capabilities for specific database dialects. Existing Text-to-SQL benchmarks such as Spider and BIRD primarily focus on SQLite-compatible syntax, while DS-NL2SQL fills the gap in grammatical specificity and heterogeneity of real enterprise database dialects. This dataset provides parallel multi-dialect NL-SQL pairs, with emphasis on complex queries featuring strict grammatical constraints, implicit cross-clause dependencies, and varying function signatures across different database engines. Key features include: - **Scale**: It contains 2,218 test samples covering 796 distinct databases. - **Supported Heterogeneous Dialects (6 Total)**: SQLite (v3.45.3), MySQL (v8.0.45), PostgreSQL (v14.20), SQL Server (v17.0), DuckDB (v1.4.3), and Oracle Database (19c). - **High Dialect Variability**: Each sample has an average dialect difference score of 3.67, compared to 1.60 for BIRD Mini-Dev, ensuring strict evaluation of engine-specific constraints. - **Focus on Dialect Incompatibility**: Only queries exhibiting dialect exclusivity (i.e., queries that fail on at least one system due to dialect mismatch) are retained, while generic cross-system queries such as simple `SELECT * FROM table` are excluded. - **Guaranteed Execution Equivalence**: All parallel SQL variants have been rigorously validated (and manually corrected when automated tools failed) to ensure strictly consistent execution results across all target database engines. The dataset is sourced from multiple mainstream datasets including Spider, BIRD, SParC, CoSQL, OmniSQL, and Archer. It is provided in JSON format, with each entry containing the database ID, natural language user intent, and gold-standard SQL for each dialect.
DS-NL2SQL 数据集概述
基本信息
- 数据集名称: DS-NL2SQL
- 主要用途: 用于评估特定于数据库方言的自然语言转SQL(NL2SQL)生成
- 任务类别: 表格问答
- 语言: 英语
- 许可协议: MIT
- 数据规模: 1K<n<10K
- 标签: nl2sql, text-to-sql, database, sql, multi-dialect, benchmark
核心特点
- 规模: 包含 2,218 个测试样本,覆盖 796 个不同的数据库。
- 支持的异构方言: 支持 6 种数据库方言:SQLite (v3.45.3)、MySQL (v8.0.45)、PostgreSQL (v14.20)、SQL Server (v17.0)、DuckDB (v1.4.3) 和 Oracle Database (19c)。
- 高方言差异: 每个样本的平均方言差异为 3.67 分,确保了针对引擎特定约束的严格评估。
- 方言不兼容性聚焦: 仅保留表现出方言排他性的查询,即由于方言不匹配导致至少在一个系统上失败的查询。通用的跨系统查询被排除。
- 执行等价性保证: 所有并行的SQL变体都经过精心验证,以确保在所有目标数据库引擎上的执行结果严格一致。
数据来源
自然语言查询和数据库模式聚合自多个主流数据集:
- Spider (https://yale-lily.github.io/spider)
- BIRD (https://bird-bench.github.io/)
- SParC (https://yale-lily.github.io/sparc)(重写为自包含查询)
- CoSQL (https://yale-lily.github.io/cosql)(重写为自包含查询)
- OmniSQL (https://omnisql.github.io/)
- Archer (https://github.com/danna-zheng/Archer)
数据结构
数据集以JSON格式提供。每个项目包含以下主要字段: json { "db_id": "database_name", "question": "The natural language user intent.", "gold_sql": { "sqlite": "SELECT ...", "mysql": "SELECT ...", "postgres": "SELECT ...", "sqlserver": "SELECT ...", "duckdb": "SELECT ...", "oracle": "SELECT ..." } }
物理数据库设置:数据集迁移工具
该工具将SQLite数据库迁移到MySQL、PostgreSQL、SQL Server和DuckDB。旨在与 duckdb_sqlite_databases.zip 配合使用,并将多方言评估扩展到五个数据库引擎。
工具概述
- 源: SQLite数据库文件
- 目标: MySQL、PostgreSQL、SQL Server、DuckDB
- 特点: 智能迁移、可选重用现有数据库、可按引擎配置启用/禁用
快速开始
- 提取
duckdb_sqlite_databases.zip。 - 在
dataset/config.py中配置路径和凭据。 - 运行迁移脚本:
python run_migration.py。
配置参考
| 配置项 | 描述 |
|---|---|
SQLITE_BASE_DIR |
SQLite文件的基础路径 |
MIGRATION_TARGETS |
要迁移到的引擎列表 |
MIGRATION_ROW_LIMIT |
每个表的最大额外行数(默认:50) |
REUSE_EXISTING_DB |
如果数据库存在则跳过创建(默认:True) |
DUCKDB_STORAGE_PATH |
DuckDB输出目录 |
CHECKPOINT_INTERVAL |
每N个数据库保存中间结果(默认:50) |
相关资源
引用
bibtex @article{dial2024, title={Dial: A Knowledge-Grounded Dialect-Specific NL2SQL System}, author={Zhang, Xiang and others}, journal={arXiv preprint arXiv:2603.07449}, year={2024} }




