Commit 1a87a16
committed
[SPARK-22934][SQL] Make optional clauses order insensitive for CREATE TABLE SQL statement
## What changes were proposed in this pull request?
Currently, our CREATE TABLE syntax require the EXACT order of clauses. It is pretty hard to remember the exact order. Thus, this PR is to make optional clauses order insensitive for `CREATE TABLE` SQL statement.
```
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] [db_name.]table_name
[(col_name1 col_type1 [COMMENT col_comment1], ...)]
USING datasource
[OPTIONS (key1=val1, key2=val2, ...)]
[PARTITIONED BY (col_name1, col_name2, ...)]
[CLUSTERED BY (col_name3, col_name4, ...) INTO num_buckets BUCKETS]
[LOCATION path]
[COMMENT table_comment]
[TBLPROPERTIES (key1=val1, key2=val2, ...)]
[AS select_statement]
```
The proposal is to make the following clauses order insensitive.
```
[OPTIONS (key1=val1, key2=val2, ...)]
[PARTITIONED BY (col_name1, col_name2, ...)]
[CLUSTERED BY (col_name3, col_name4, ...) INTO num_buckets BUCKETS]
[LOCATION path]
[COMMENT table_comment]
[TBLPROPERTIES (key1=val1, key2=val2, ...)]
```
The same idea is also applicable to Create Hive Table.
```
CREATE [EXTERNAL] TABLE [IF NOT EXISTS] [db_name.]table_name
[(col_name1[:] col_type1 [COMMENT col_comment1], ...)]
[COMMENT table_comment]
[PARTITIONED BY (col_name2[:] col_type2 [COMMENT col_comment2], ...)]
[ROW FORMAT row_format]
[STORED AS file_format]
[LOCATION path]
[TBLPROPERTIES (key1=val1, key2=val2, ...)]
[AS select_statement]
```
The proposal is to make the following clauses order insensitive.
```
[COMMENT table_comment]
[PARTITIONED BY (col_name2[:] col_type2 [COMMENT col_comment2], ...)]
[ROW FORMAT row_format]
[STORED AS file_format]
[LOCATION path]
[TBLPROPERTIES (key1=val1, key2=val2, ...)]
```
## How was this patch tested?
Added test cases
Author: gatorsmile <[email protected]>
Closes #20133 from gatorsmile/createDataSourceTableDDL.1 parent 247a089 commit 1a87a16
File tree
7 files changed
+335
-138
lines changed- sql
- catalyst/src/main
- antlr4/org/apache/spark/sql/catalyst/parser
- scala/org/apache/spark/sql/catalyst/parser
- core/src
- main/scala/org/apache/spark/sql/execution
- test/scala/org/apache/spark/sql/execution/command
- hive/src/test/scala/org/apache/spark/sql/hive/execution
7 files changed
+335
-138
lines changedLines changed: 14 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
88 | 92 | | |
89 | 93 | | |
90 | 94 | | |
| |||
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
| |||
39 | 41 | | |
40 | 42 | | |
41 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
42 | 51 | | |
43 | 52 | | |
44 | 53 | | |
| |||
Lines changed: 56 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
383 | 383 | | |
384 | 384 | | |
385 | 385 | | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
| 386 | + | |
395 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
396 | 399 | | |
397 | 400 | | |
398 | 401 | | |
399 | 402 | | |
400 | 403 | | |
401 | 404 | | |
402 | 405 | | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
403 | 414 | | |
404 | 415 | | |
405 | 416 | | |
| |||
408 | 419 | | |
409 | 420 | | |
410 | 421 | | |
411 | | - | |
| 422 | + | |
412 | 423 | | |
413 | | - | |
| 424 | + | |
414 | 425 | | |
415 | 426 | | |
416 | 427 | | |
| |||
1087 | 1098 | | |
1088 | 1099 | | |
1089 | 1100 | | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
| 1101 | + | |
1096 | 1102 | | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
1097 | 1111 | | |
1098 | 1112 | | |
1099 | 1113 | | |
| |||
1104 | 1118 | | |
1105 | 1119 | | |
1106 | 1120 | | |
1107 | | - | |
| 1121 | + | |
1108 | 1122 | | |
1109 | 1123 | | |
1110 | 1124 | | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
1111 | 1133 | | |
1112 | 1134 | | |
1113 | | - | |
| 1135 | + | |
1114 | 1136 | | |
1115 | | - | |
| 1137 | + | |
1116 | 1138 | | |
1117 | 1139 | | |
1118 | 1140 | | |
1119 | 1141 | | |
1120 | 1142 | | |
1121 | 1143 | | |
1122 | 1144 | | |
1123 | | - | |
1124 | | - | |
| 1145 | + | |
| 1146 | + | |
1125 | 1147 | | |
1126 | | - | |
| 1148 | + | |
1127 | 1149 | | |
1128 | | - | |
| 1150 | + | |
1129 | 1151 | | |
1130 | 1152 | | |
1131 | 1153 | | |
| |||
1180 | 1202 | | |
1181 | 1203 | | |
1182 | 1204 | | |
1183 | | - | |
| 1205 | + | |
1184 | 1206 | | |
1185 | 1207 | | |
1186 | 1208 | | |
| |||
1366 | 1388 | | |
1367 | 1389 | | |
1368 | 1390 | | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
1369 | 1400 | | |
1370 | 1401 | | |
1371 | 1402 | | |
| |||
0 commit comments