Datasets:
|
Download README.md from hzn666/DS-NL2SQL: direct link, hf CLI and curl.
- Browser
- Download file 5.63 kB
-
https://huggingface.co/datasets/hzn666/DS-NL2SQL/resolve/main/README.md
- Command line
-
hf download hf://datasets/hzn666/DS-NL2SQL/README.md
-
curl -L -o README.md https://huggingface.co/datasets/hzn666/DS-NL2SQL/resolve/main/README.md
5.63 kB
| language: | |
| - en | |
| license: mit | |
| size_categories: | |
| - 1K<n<10K | |
| pretty_name: DS-NL2SQL | |
| task_categories: | |
| - table-question-answering | |
| tags: | |
| - nl2sql | |
| - text-to-sql | |
| - database | |
| - sql | |
| - multi-dialect | |
| - benchmark | |
| # DS-NL2SQL: A Benchmark for Dialect-Specific NL2SQL | |
| **Paper:** [Dial: A Knowledge-Grounded Dialect-Specific NL2SQL System](https://huggingface.co/papers/2603.07449) | |
| **Code Repository:** [weAIDB/Dial](https://github.com/weAIDB/Dial) | |
| ## Dataset Overview | |
| Existing Text-to-SQL benchmarks (such as Spider and BIRD) predominantly focus on SQLite-compatible syntax, failing to capture the syntax specificity and heterogeneity inherent in real-world enterprise database dialects. To bridge this gap, we introduce **DS-NL2SQL**, a high-quality, multi-dialect NL2SQL benchmark designed to evaluate dialect-specific SQL generation. | |
| DS-NL2SQL provides parallel multi-dialect NL-SQL pairs and emphasizes complex queries with strict syntax constraints, implicit cross-clause dependencies, and varying function signatures across different database engines. | |
| ### Key Features | |
| - **Scale:** 2,218 test samples across 796 distinct databases. | |
| - **Heterogeneous Dialects Supported (6):** SQLite (v3.45.3), MySQL (v8.0.45), PostgreSQL (v14.20), SQL Server (v17.0), DuckDB (v1.4.3), and Oracle Database (19c). | |
| - **High Dialectal Discrepancy:** Features an average dialect discrepancy of 3.67 points per sample (compared to 1.60 for BIRD Mini-Dev), ensuring rigorous assessment of engine-specific constraints. | |
| - **Dialect Incompatibility Focus:** Retains only queries that exhibit dialect exclusivity (i.e., queries that fail on at least one system due to dialect mismatch). Generic cross-system queries (e.g., simple `SELECT * FROM table`) are excluded. | |
| - **Execution Equivalence Guaranteed:** All parallel SQL variations have been meticulously verified (and manually corrected where automated tools failed) to ensure that execution results remain strictly consistent across all target database engines. | |
| ### Data Sources | |
| The natural language queries and database schemas are aggregated from multiple mainstream datasets: | |
| - [Spider](https://yale-lily.github.io/spider) | |
| - [BIRD](https://bird-bench.github.io/) | |
| - [SParC](https://yale-lily.github.io/sparc) (Rewritten into self-contained queries) | |
| - [CoSQL](https://yale-lily.github.io/cosql) (Rewritten into self-contained queries) | |
| - [OmniSQL](https://omnisql.github.io/) | |
| - [Archer](https://github.com/danna-zheng/Archer) | |
| --- | |
| ## Dataset Structure | |
| The benchmark is provided in JSON format. Each item contains the following primary fields: | |
| ```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 ..." | |
| } | |
| } | |
| ``` | |
| --- | |
| # Physical Database Setup: Dataset Migration Tool | |
| Migrates SQLite databases to MySQL, PostgreSQL, SQL Server, and DuckDB. Designed to work with `duckdb_sqlite_databases.zip` and extend multi-dialect evaluation to five database engines. | |
| ## Overview | |
| - **Source**: SQLite database files (e.g. from `duckdb_sqlite_databases.zip`) | |
| - **Targets**: MySQL, PostgreSQL, SQL Server, DuckDB (Oracle requires additional implementation) | |
| - **Features**: Smart migration (only essential rows for queries), optional reuse of existing databases, configurable per-engine enable/disable | |
| ## Quick Start | |
| ### 1. Extract `duckdb_sqlite_databases.zip` | |
| After extraction you typically have: | |
| ``` | |
| duckdb_sqlite_databases/ | |
| ├── sqlite_databases/ | |
| │ ├── {db_id_1}/ | |
| │ │ └── {db_id_1}.sqlite | |
| │ ├── {db_id_2}/ | |
| │ │ └── {db_id_2}.sqlite | |
| │ └── ... | |
| └── duckdb_databases/ (optional; we can create from SQLite) | |
| └── ... | |
| ``` | |
| ### 2. Configure Paths and Credentials | |
| Edit `dataset/config.py`: | |
| - **SQLITE_BASE_DIR**: Path to the `sqlite_databases/` directory (or use env `SQLITE_BASE_DIR`) | |
| - **DUCKDB_STORAGE_PATH**: Where to store DuckDB files (empty = temp dir, cleaned after run) | |
| - **DB_CONFIG**: Connection settings for MySQL, Postgres, SQL Server | |
| Example: | |
| ```python | |
| SQLITE_BASE_DIR = r"C:\path\to\duckdb_sqlite_databases\sqlite_databases" | |
| DUCKDB_STORAGE_PATH = r"C:\path\to\duckdb_sqlite_databases\duckdb_databases" | |
| DB_CONFIG = { | |
| "mysql": {"host": "localhost", "user": "root", "password": "123456", "port": 3306}, | |
| "postgres": {"host": "localhost", "user": "postgres", "password": "123456", "port": 5432}, | |
| "sqlserver": {"host": "localhost", "user": "sa", "password": "xxx", "port": 1433, "driver": "{ODBC Driver 17 for SQL Server}"}, | |
| } | |
| ``` | |
| Or use environment variables: | |
| ```bash | |
| set SQLITE_BASE_DIR=C:\path\to\duckdb_sqlite_databases\sqlite_databases | |
| set MYSQL_HOST=localhost | |
| set PG_HOST=localhost | |
| set SQLSERVER_HOST=localhost | |
| ``` | |
| ### 3. Run Migration | |
| From project root (recommended): | |
| ```bash | |
| python run_migration.py | |
| ``` | |
| ## Configuration Reference | |
| | Config | Description | | |
| |--------|-------------| | |
| | `SQLITE_BASE_DIR` | Base path for SQLite files | | |
| | `MIGRATION_TARGETS` | List of engines to migrate to | | |
| | `MIGRATION_ROW_LIMIT` | Max extra rows per table (default: 50) | | |
| | `REUSE_EXISTING_DB` | Skip creation if DB exists (default: True) | | |
| | `DUCKDB_STORAGE_PATH` | DuckDB output dir (empty = temp) | | |
| | `CHECKPOINT_INTERVAL` | Save intermediate results every N DBs (default: 50) | | |
| ## Citation | |
| ```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} | |
| } | |
| ``` |