cloud-fan commented on a change in pull request #23259: [SPARK-26215][SQL]
Define reserved/non-reserved keywords based on the ANSI SQL standard
URL: https://github.com/apache/spark/pull/23259#discussion_r258912509
##########
File path:
sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
##########
@@ -720,14 +725,18 @@ qualifiedName
identifier
: strictIdentifier
+ // We can't move the tokens below into `strictIdentifier` because we need
to parse some SQL texts,
+ // e.g., SELECT * FROM t1 CROSS JOIN t2
| ANTI | FULL | INNER | LEFT | SEMI | RIGHT | NATURAL | JOIN | CROSS | ON
| UNION | INTERSECT | EXCEPT | SETMINUS
;
strictIdentifier
- : IDENTIFIER #unquotedIdentifier
- | quotedIdentifier #quotedIdentifierAlternative
- | nonReserved #unquotedIdentifier
+ : IDENTIFIER #unquotedIdentifier
+ | quotedIdentifier #quotedIdentifierAlternative
+ | {ansi}? ansiReserved #unquotedIdentifier
Review comment:
> `sql("select 1 as select from (select 1)")` throws an exception cuz of the
reserved keyword `select`
Isn't it what we expect? That's how reserved keywords should behave, right?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]