Reetu Raj Harsh commited on
Commit
eb25f92
·
verified ·
1 Parent(s): 653b16e

Upload Text2SQL dataset with 34 SQLite databases and metadata files

Browse files
Files changed (2) hide show
  1. README.md +49 -29
  2. schemas/database_schemas.yaml +0 -0
README.md CHANGED
@@ -95,7 +95,7 @@ finch/
95
 
96
  ### Data Files Structure
97
  - **`finch_dataset.json`**: Main dataset file with 75,725 NL-SQL pairs (appears in HF dataset viewer)
98
- - **`schemas/database_schemas.json`**: Database schema metadata for all 33 databases (auxiliary file)
99
  - **`text2sql-db/`**: SQLite database files organized by source (auxiliary files)
100
 
101
  ### Sample Data from finch_dataset.json
@@ -132,28 +132,48 @@ finch/
132
  ]
133
  ```
134
 
135
- ### Schema Information (schemas/database_schemas.json)
136
-
137
- The `schemas/database_schemas.json` file contains comprehensive schema metadata for all databases:
138
-
139
- ```json
140
- {
141
- "financial": {
142
- "db_id": "financial",
143
- "table_names_original": ["account", "card", "client", "disp", "district", "loan", "order", "trans"],
144
- "table_names": ["account", "card", "client", "disposition", "district", "loan", "order", "transaction"],
145
- "column_names_original": [
146
- [-1, "*"],
147
- [0, "account_id"],
148
- [0, "district_id"],
149
- [0, "frequency"],
150
- [0, "date"]
151
- ],
152
- "column_types": ["text", "number", "number", "text", "text"],
153
- "foreign_keys": [[2, 1], [4, 2]],
154
- "primary_keys": [1]
155
- }
156
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  ```
158
 
159
  ## Example Usage
@@ -166,9 +186,10 @@ The `schemas/database_schemas.json` file contains comprehensive schema metadata
166
  from datasets import load_dataset
167
  from huggingface_hub import hf_hub_download
168
  import sqlite3
 
169
 
170
  # Load the main dataset using HuggingFace datasets library
171
- dataset = load_dataset("reeturajahrsh1907/finch")
172
  print(f"Dataset: {dataset}")
173
  print(f"Number of examples: {len(dataset['train'])}")
174
 
@@ -180,14 +201,13 @@ print(f"Database: {sample['db_id']}")
180
  print(f"Difficulty: {sample['difficulty']}")
181
 
182
  # Load schema information for the database
183
- schema_path = hf_hub_download(repo_id="reeturajahrsh1907/finch", filename="schemas/database_schemas.json")
184
- import json
185
  with open(schema_path, 'r') as f:
186
- schemas = json.load(f)
187
 
188
  # Download the corresponding SQLite database
189
  db_path = hf_hub_download(
190
- repo_id="reeturajahrsh1907/finch",
191
  filename=f"text2sql-db/text2sql/bird/{sample['db_id']}.sqlite"
192
  )
193
 
@@ -207,7 +227,7 @@ import sqlite3
207
  from huggingface_hub import hf_hub_download
208
 
209
  # Alternative: Load dataset JSON file directly
210
- samples_path = hf_hub_download(repo_id="reeturajahrsh1907/finch", filename="finch_dataset.json")
211
  with open(samples_path, 'r') as f:
212
  dataset = json.load(f)
213
 
 
95
 
96
  ### Data Files Structure
97
  - **`finch_dataset.json`**: Main dataset file with 75,725 NL-SQL pairs (appears in HF dataset viewer)
98
+ - **`schemas/database_schemas.yaml`**: Database schema metadata for all 33 databases (auxiliary file)
99
  - **`text2sql-db/`**: SQLite database files organized by source (auxiliary files)
100
 
101
  ### Sample Data from finch_dataset.json
 
132
  ]
133
  ```
134
 
135
+ ### Schema Information (schemas/database_schemas.yaml)
136
+
137
+ The `schemas/database_schemas.yaml` file contains comprehensive schema metadata for all databases:
138
+
139
+ ```yaml
140
+ financial:
141
+ db_id: financial
142
+ table_names_original:
143
+ - account
144
+ - card
145
+ - client
146
+ - disp
147
+ - district
148
+ - loan
149
+ - order
150
+ - trans
151
+ table_names:
152
+ - account
153
+ - card
154
+ - client
155
+ - disposition
156
+ - district
157
+ - loan
158
+ - order
159
+ - transaction
160
+ column_names_original:
161
+ - [-1, "*"]
162
+ - [0, "account_id"]
163
+ - [0, "district_id"]
164
+ - [0, "frequency"]
165
+ - [0, "date"]
166
+ column_types:
167
+ - text
168
+ - number
169
+ - number
170
+ - text
171
+ - text
172
+ foreign_keys:
173
+ - [2, 1]
174
+ - [4, 2]
175
+ primary_keys:
176
+ - 1
177
  ```
178
 
179
  ## Example Usage
 
186
  from datasets import load_dataset
187
  from huggingface_hub import hf_hub_download
188
  import sqlite3
189
+ import yaml
190
 
191
  # Load the main dataset using HuggingFace datasets library
192
+ dataset = load_dataset("domyn/finch")
193
  print(f"Dataset: {dataset}")
194
  print(f"Number of examples: {len(dataset['train'])}")
195
 
 
201
  print(f"Difficulty: {sample['difficulty']}")
202
 
203
  # Load schema information for the database
204
+ schema_path = hf_hub_download(repo_id="domyn/finch", filename="schemas/database_schemas.yaml")
 
205
  with open(schema_path, 'r') as f:
206
+ schemas = yaml.safe_load(f)
207
 
208
  # Download the corresponding SQLite database
209
  db_path = hf_hub_download(
210
+ repo_id="domyn/finch",
211
  filename=f"text2sql-db/text2sql/bird/{sample['db_id']}.sqlite"
212
  )
213
 
 
227
  from huggingface_hub import hf_hub_download
228
 
229
  # Alternative: Load dataset JSON file directly
230
+ samples_path = hf_hub_download(repo_id="domyn/finch", filename="finch_dataset.json")
231
  with open(samples_path, 'r') as f:
232
  dataset = json.load(f)
233
 
schemas/database_schemas.yaml ADDED
The diff for this file is too large to render. See raw diff