bayerth commited on
Commit
74386a4
·
verified ·
1 Parent(s): 10d3853

Add refined sql-create-context

Browse files
Files changed (3) hide show
  1. .gitattributes +1 -0
  2. README.md +193 -0
  3. sql_context_v2.json +3 -0
.gitattributes CHANGED
@@ -58,3 +58,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ sql_context_v2.json filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - en
5
+ pretty_name: sql-create-context refined
6
+ size_categories:
7
+ - 10K<n<100K
8
+ task_categories:
9
+ - text-generation
10
+ - question-answering
11
+ tags:
12
+ - text-to-sql
13
+ - SQL
14
+ - refinement
15
+ - spider
16
+ source_datasets:
17
+ - philschmid/sql-create-context-copy
18
+ - b-mc2/sql-create-context
19
+ dataset_info:
20
+ config_name: default
21
+ features:
22
+ - name: question
23
+ dtype: string
24
+ - name: answer
25
+ dtype: string
26
+ - name: context
27
+ dtype: string
28
+ - name: dialect
29
+ dtype: string
30
+ - name: spider_hardness
31
+ dtype: string
32
+ - name: extended_hardness
33
+ dtype: string
34
+ - name: classification_status
35
+ dtype: string
36
+ - name: syntax_status
37
+ dtype: string
38
+ - name: ddl_syntax_status
39
+ dtype: string
40
+ - name: schema_status
41
+ dtype: string
42
+ - name: syntax_errors
43
+ sequence: string
44
+ - name: ddl_syntax_errors
45
+ sequence: string
46
+ - name: schema_errors
47
+ sequence: string
48
+ - name: classification_errors
49
+ sequence: string
50
+ - name: status_history
51
+ sequence: string
52
+ - name: correction_status
53
+ dtype: string
54
+ - name: component1
55
+ dtype: int64
56
+ - name: component2
57
+ dtype: int64
58
+ - name: others
59
+ dtype: int64
60
+ - name: validation_source
61
+ struct:
62
+ - name: split
63
+ dtype: string
64
+ - name: row_index
65
+ dtype: int64
66
+ splits:
67
+ - name: train
68
+ num_bytes: 70395555
69
+ num_examples: 78577
70
+ configs:
71
+ - config_name: default
72
+ data_files:
73
+ - split: train
74
+ path: sql_context_v2.json
75
+ ---
76
+
77
+ # sql-create-context refined
78
+
79
+ This dataset is a refinement of
80
+ [philschmid/sql-create-context-copy](https://huggingface.co/datasets/philschmid/sql-create-context-copy).
81
+ It is not a new collection of questions. The copy is itself a duplicate of
82
+ [b-mc2/sql-create-context](https://huggingface.co/datasets/b-mc2/sql-create-context).
83
+ Row order and the 78,577 questions are preserved. The SQL answers are
84
+ preserved except for quote normalisation and 541 structural repairs. The
85
+ `CREATE TABLE` context is preserved or expanded, and every row has
86
+ `extended_hardness`. Where the official Spider adapter accepts the statement,
87
+ the row also has `spider_hardness`.
88
+
89
+ The dataset file is `data/sql/sql_context_v2.json` in the
90
+ [sql_tools](https://github.com/bayerth/sql_tools) repository. On the Hub the
91
+ same file is `sql_context_v2.json`, next to this `README.md`.
92
+
93
+ ## What changed relative to sql-create-context-copy
94
+
95
+ | Step | What it does to the copy | Rows affected |
96
+ | --- | --- | ---: |
97
+ | Quote rewrite | Double-quoted string literals in `answer` become single-quoted SQL strings. An apostrophe inside a literal is doubled. `question` and `context` are copied unchanged. Three `FROM "t"` table names stay double-quoted. | 62,967 statements changed; 503 apostrophes doubled |
98
+ | Validation | Generic SQLGlot check of SQL syntax, DDL syntax, and schema references. No SQL is executed. | 78,036 valid; 541 rejected |
99
+ | Repair | Only the 541 rejected rows are rewritten. A candidate is kept only when the new SQL and DDL validate. | 541 applied |
100
+ | DDL expansion | A model may add columns and give bare `VARCHAR` a length. The SQL query is not changed. Failed expansions keep the previous DDL. | 68,983 expanded; 8,025 unchanged; 1,569 failed, all kept |
101
+ | Hardness | `spider_hardness` where the official adapter accepts the statement, and `extended_hardness` on every row. | 78,577 extended labels; 75,382 Spider labels |
102
+
103
+ `dialect` is `generic` on the 78,036 rows that passed the first validation, and
104
+ `mysql` on the 541 repaired rows. `correction_status` is `corrected` on those
105
+ 541 rows and empty otherwise. Compare `spider_hardness` and
106
+ `extended_hardness` only when both are set. They use the same names
107
+ (`easy`, `medium`, `hard`, `extra`). `extended_hardness` can also be
108
+ `extreme`.
109
+
110
+ ## Hardness counts
111
+
112
+ Spider shares are of the 75,382 rows with a Spider label. Extended shares are
113
+ of all 78,577 rows.
114
+
115
+ | Label | Spider | Extended |
116
+ | --- | ---: | ---: |
117
+ | easy | 51,082 | 53,001 |
118
+ | medium | 22,693 | 23,957 |
119
+ | hard | 913 | 921 |
120
+ | extra | 694 | 690 |
121
+ | extreme | | 8 |
122
+ | labeled | 75,382 | 78,577 |
123
+
124
+ `classification_status` is `classified` when both labels are set (75,382 rows)
125
+ and `extended` when only `extended_hardness` is set (3,195 rows). No row lacks
126
+ an extended label. The last entry of `status_history` is the same value.
127
+
128
+ ## Columns
129
+
130
+ Training and evaluation use `question`, `answer`, `context`, `dialect`,
131
+ `spider_hardness`, and `extended_hardness`.
132
+
133
+ | Column | Meaning |
134
+ | --- | --- |
135
+ | `question` | Natural-language question, unchanged from the copy. |
136
+ | `answer` | SQL query. Quotes are normalised. SQL text changes only on the 541 repaired rows. |
137
+ | `context` | One or more `CREATE TABLE` statements. Expanded rows have a richer DDL; unchanged and failed rows keep the previous DDL. |
138
+ | `dialect` | `generic`, or `mysql` on a repaired row. |
139
+ | `spider_hardness` | `easy`, `medium`, `hard`, `extra`, or empty. |
140
+ | `extended_hardness` | `easy`, `medium`, `hard`, `extra`, or `extreme`. Always set. |
141
+ | `classification_status` | `classified` or `extended`. |
142
+ | `syntax_status`, `ddl_syntax_status`, `schema_status` | Result of the structural checks. |
143
+ | `syntax_errors`, `ddl_syntax_errors`, `schema_errors`, `classification_errors` | Diagnostic lists. Empty when the check passed. |
144
+ | `status_history` | Ordered record of the pipeline events for the row. |
145
+ | `correction_status` | `corrected` on repaired rows; empty otherwise. |
146
+ | `component1`, `component2`, `others` | Spider counters. Empty when `spider_hardness` is empty. |
147
+ | `validation_source` | Split name and row index in the source copy. |
148
+
149
+ ## Limitations
150
+
151
+ Validation and hardness do not execute SQL. A row can be structurally valid
152
+ and still be a poor answer to its question. The 541 repairs were accepted
153
+ because the repaired SQL and DDL parse and the names resolve, not because a
154
+ database returned the expected rows. Columns added during expansion were
155
+ proposed by `openai/gpt-oss-120b`. They are not columns from a production
156
+ schema. Hardness measures statement shape, not how difficult a person would
157
+ find the question.
158
+
159
+ ## License and attribution
160
+
161
+ The source dataset is released under
162
+ [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). This refinement is
163
+ distributed under the same license. Cite the source dataset as well as this
164
+ refinement.
165
+
166
+ ## Citation
167
+
168
+ ```bibtex
169
+ @misc{bayer2026sqlcreatecontextrefined,
170
+ title = {sql-create-context refined},
171
+ author = {Bayer, Thomas and Grok},
172
+ year = {2026},
173
+ url = {https://github.com/bayerth/sql_tools},
174
+ note = {Refinement of philschmid/sql-create-context-copy, itself a duplicate of b-mc2/sql-create-context.}
175
+ }
176
+
177
+ @misc{bmc2_2023_sqlcreatecontext,
178
+ title = {sql-create-context Dataset},
179
+ author = {b-mc2},
180
+ year = {2023},
181
+ url = {https://huggingface.co/datasets/b-mc2/sql-create-context},
182
+ note = {Built by modifying WikiSQL and Spider.}
183
+ }
184
+
185
+ @inproceedings{yu2018spider,
186
+ title = {Spider: A Large-Scale Human-Labeled Dataset for Complex and Cross-Domain Semantic Parsing and Text-to-{SQL} Task},
187
+ author = {Yu, Tao and Zhang, Rui and Yang, Kai and Yasunaga, Michihiro and Wang, Dongxu and Li, Zifan and Ma, James and Li, Irene and Yao, Qingning and Roman, Shanelle and Zhang, Zilin and Radev, Dragomir},
188
+ booktitle = {Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing},
189
+ pages = {3911--3921},
190
+ year = {2018},
191
+ address = {Brussels, Belgium}
192
+ }
193
+ ```
sql_context_v2.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26de2d2da326b2093bde0800e6f4178489c83f58befcf8fd218c81e57e035bdf
3
+ size 70395555