LadyForest commented on a change in pull request #15005:
URL: https://github.com/apache/flink/pull/15005#discussion_r582786889



##########
File path: flink-table/flink-sql-parser-hive/src/main/codegen/data/Parser.tdd
##########
@@ -129,6 +130,7 @@
     "LINES"
     "LOAD"
     "LOCATION"
+    "MODULES"

Review comment:
       Hi Jark, this is the point I've struggled with. The `USE database` 
syntax takes a compound identifier for the database name, and the non-reserved 
keyword will be matched and cause a parse failure.
   
   The grammar for `USE db`
   ```
   SqlUseDatabase SqlUseDatabase() :
   {
       SqlIdentifier databaseName;
       SqlParserPos pos;
   }
   {
       <USE> { pos = getPos();}
       databaseName = CompoundIdentifier()
       {
           return new SqlUseDatabase(pos, databaseName);
       }
   }
   ```
   
   The grammar for `IdentiiferSegment` of `CompoundIdentifier`
   
   ```
   void IdentifierSegment(List<String> names, List<SqlParserPos> positions) :
   {
       final String id;
       char unicodeEscapeChar = BACKSLASH;
       final SqlParserPos pos;
       final Span span;
   }
   {
       (
           <IDENTIFIER> {
              ...
           }
       |
           <HYPHENATED_IDENTIFIER> {
               ...
           }
       |
           <QUOTED_IDENTIFIER> {
               ...
           }
       |
           <BACK_QUOTED_IDENTIFIER> {
              ...
           }
       |
           <BRACKET_QUOTED_IDENTIFIER> {
              ...
           }
       |
           <UNICODE_QUOTED_IDENTIFIER> {
               ...
           }
           [
               <UESCAPE> <QUOTED_STRING> {
                   ...
               }
           ]
           {
               ...
           }
       |
           id = NonReservedKeyWord() {
               pos = getPos();
           }
       )
     ...
   }
   ```
   You can check the parser.jj template or generated parser.jj file to identify 
it, and I'm open to your suggestions




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to