Skip to content

Commit

Permalink
[SPARK-26905][SQL] Add TYPE in the ANSI non-reserved list
Browse files Browse the repository at this point in the history
### What changes were proposed in this pull request?

This PR intends to add `TYPE` in the ANSI non-reserved list because it is not reserved in the standard. See SPARK-26905 for a full set of the reserved/non-reserved keywords of `SQL:2016`.

Note: The current master behaviour is as follows;
```
scala> sql("SET spark.sql.ansi.enabled=false")
scala> sql("create table t1 (type int)")
res4: org.apache.spark.sql.DataFrame = []

scala> sql("SET spark.sql.ansi.enabled=true")
scala> sql("create table t2 (type int)")
org.apache.spark.sql.catalyst.parser.ParseException:
no viable alternative at input 'type'(line 1, pos 17)

== SQL ==
create table t2 (type int)
-----------------^^^
```

### Why are the changes needed?

To follow the ANSI/SQL standard.

### Does this PR introduce _any_ user-facing change?

Makes users use `TYPE` as identifiers.

### How was this patch tested?

Update the keyword lists in `TableIdentifierParserSuite`.

Closes #28773 from maropu/SPARK-26905.

Authored-by: Takeshi Yamamuro <yamamuro@apache.org>
Signed-off-by: Takeshi Yamamuro <yamamuro@apache.org>
  • Loading branch information
maropu committed Jun 10, 2020
1 parent f3771c6 commit e14029b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,7 @@ ansiNonReserved
| TRIM
| TRUE
| TRUNCATE
| TYPE
| UNARCHIVE
| UNBOUNDED
| UNCACHE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ class TableIdentifierParserSuite extends SparkFunSuite with SQLHelper {
"transform",
"true",
"truncate",
"type",
"unarchive",
"unbounded",
"uncache",
Expand Down

0 comments on commit e14029b

Please sign in to comment.