-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-26905][SQL] Follow the SQL:2016 reserved keywords #28807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Test build #123894 has finished for PR 28807 at commit
|
|
retest this please |
|
Test build #123896 has finished for PR 28807 at commit
|
|
retest this please |
|
Test build #123929 has finished for PR 28807 at commit
|
|
retest this please |
|
Test build #123946 has finished for PR 28807 at commit
|
| Files.copy(is, tmpFile.toPath) | ||
| val reservedKeywordsInSql2016 = Files.readAllLines(tmpFile.toPath) | ||
| .asScala.filterNot(_.startsWith("--")).map(_.trim).toSet | ||
| assert(((reservedKeywordsInAnsiMode -- Set("!")) -- reservedKeywordsInSql2016).isEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that, since NOT reserved, ! also reserved, too. (NOT: 'NOT' | '!';);
scala> sql("SET spark.sql.ansi.enabled=false")
scala> spark.sql("create table r2 (! int);")
res2: org.apache.spark.sql.DataFrame = []
scala> sql("SET spark.sql.ansi.enabled=true")
scala> spark.sql("create table r2 (! int);")
org.apache.spark.sql.catalyst.parser.ParseException:
no viable alternative at input '!'(line 1, pos 17)
== SQL ==
create table r2 (! int);
-----------------^^^
@cloud-fan Is this expected? FYI: It seems PostgreSQL cannot accept ! in column names;
postgres=# create table r2 (! int);
2020-06-13 11:30:24.495 JST [36406] ERROR: syntax error at or near "!" at character 18
2020-06-13 11:30:24.495 JST [36406] STATEMENT: create table r2 (! int);
ERROR: syntax error at or near "!"
LINE 1: create table r2 (! int);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's intentional, but we can't break it now. If it's forbidden under ansi mode, I think it's good enough?
|
Test build #123944 has finished for PR 28807 at commit
|
|
Test build #123959 has finished for PR 28807 at commit
|
|
retest this please |
|
Test build #123971 has finished for PR 28807 at commit
|
| s"${reservedKeywordsInAnsiMode.size} found.") | ||
| } | ||
|
|
||
| test("should follow reserved keywords in SQL:2016") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make the test name clear? What we are testing is: reserved keywords in Spark are also reserved in SQL 2016
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks clearer, okay, I'll update. Thanks!
| Files.copy(is, tmpFile.toPath) | ||
| val reservedKeywordsInSql2016 = Files.readAllLines(tmpFile.toPath) | ||
| .asScala.filterNot(_.startsWith("--")).map(_.trim).toSet | ||
| assert(((reservedKeywordsInAnsiMode -- Set("!")) -- reservedKeywordsInSql2016).isEmpty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think symbol is not a keyword. Can we update symbolsToExpandIntoDifferentLiterals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, will do.
|
|
||
| test("check # of reserved keywords") { | ||
| val numReservedKeywords = 78 | ||
| val numReservedKeywords = 74 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: ANTI, SEMI, MINUS, and ! are removed.
|
Test build #124031 has finished for PR 28807 at commit
|
|
retest this please |
|
Test build #124041 has finished for PR 28807 at commit
|
|
Thanks! Merged to master. |
### What changes were proposed in this pull request? This PR intends to move keywords `ANTI`, `SEMI`, and `MINUS` from reserved to non-reserved. ### Why are the changes needed? To comply with the ANSI/SQL standard. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Added tests. Closes #28807 from maropu/SPARK-26905-2. Authored-by: Takeshi Yamamuro <[email protected]> Signed-off-by: Takeshi Yamamuro <[email protected]>
|
No problem. It looks okay, @maropu . |
|
Thanks for the check, @dongjoon-hyun . |
What changes were proposed in this pull request?
This PR intends to move keywords
ANTI,SEMI, andMINUSfrom reserved to non-reserved.Why are the changes needed?
To comply with the ANSI/SQL standard.
Does this PR introduce any user-facing change?
No.
How was this patch tested?
Added tests.