maropu 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_r258349724
##########
File path:
sql/catalyst/src/main/antlr4/org/apache/spark/sql/catalyst/parser/SqlBase.g4
##########
@@ -719,15 +724,17 @@ qualifiedName
;
identifier
- : strictIdentifier
+ : {ansi}? ansiReserved
Review comment:
[The antlr
doc](https://github.com/antlr/antlr4/blob/master/doc/lexer-rules.md#lexer-rule-elements)
says
```
{«p»}?: Evaluate semantic predicate «p». If «p» evaluates to false at
runtime,
the surrounding rule becomes “invisible” (nonviable). Expression «p»
conforms to
the target language syntax. While semantic predicates can appear anywhere
within a
lexer rule, it is most efficient to have them at the end of the rule. The
one caveat is
that semantic predicates must precede lexer actions. See Predicates in Lexer
Rules.
```
When `ansi` is false, the corresponding rule is just ignored, IIUC.
The generated code by antlr is as follows;
https://gist.github.com/maropu/22d13137f6cd4cf0e7e21e81a547155d#file-sqlbaseparser-java-L29-L31
https://gist.github.com/maropu/22d13137f6cd4cf0e7e21e81a547155d#file-sqlbaseparser-java-L39-L41
----------------------------------------------------------------
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]