This is an automated email from the ASF dual-hosted git repository.

nextdreamblue pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new 005eeb2e892 [fix](compatibility) add some keywords #29251 (#34428)
005eeb2e892 is described below

commit 005eeb2e892a9b186537bc342c78a9f11b354ca2
Author: xueweizhang <zxw520bl...@163.com>
AuthorDate: Thu May 9 16:43:19 2024 +0800

    [fix](compatibility) add some keywords #29251 (#34428)
    
    * [fix](compatibility) add some keywords #29251
    
    Signed-off-by: nextdreamblule <zxw520bl...@163.com>
    Co-authored-by: Mingyu Chen <morning...@163.com>
---
 .../main/antlr4/org/apache/doris/nereids/DorisLexer.g4    |  1 +
 .../main/antlr4/org/apache/doris/nereids/DorisParser.g4   | 12 +++++++-----
 fe/fe-core/src/main/cup/sql_parser.cup                    |  6 +++++-
 .../apache/doris/nereids/parser/NereidsParserTest.java    | 15 +++++++++++++++
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4
index 2a94009fc14..3793001b699 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4
@@ -122,6 +122,7 @@ BELONG: 'BELONG';
 BETWEEN: 'BETWEEN';
 BIGINT: 'BIGINT';
 BIN: 'BIN';
+BINARY: 'BINARY';
 BINLOG: 'BINLOG';
 BITAND: 'BITAND';
 BITMAP: 'BITMAP';
diff --git a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 
b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
index fd35ed7fd81..148a3f84def 100644
--- a/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
+++ b/fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4
@@ -381,9 +381,9 @@ primaryExpression
       (COMMA arguments+=expression)* (ORDER BY sortItem (COMMA sortItem)*)?)? 
RIGHT_PAREN
       (OVER windowSpec)?                                                       
                 #functionCall
     | LEFT_PAREN query RIGHT_PAREN                                             
                #subqueryExpression
-    | ATSIGN identifierOrText                                                  
                      #userVariable
-    | DOUBLEATSIGN (kind=(GLOBAL | SESSION) DOT)? identifier                   
                  #systemVariable
-    | identifier                                                               
                #columnReference
+    | ATSIGN identifierOrText                                                  
                #userVariable
+    | DOUBLEATSIGN (kind=(GLOBAL | SESSION) DOT)? identifier                   
                #systemVariable
+    | BINARY? identifier                                                       
                #columnReference
     | base=primaryExpression DOT fieldName=identifier                          
                #dereference
     | LEFT_PAREN expression RIGHT_PAREN                                        
                #parenthesizedExpression
     | EXTRACT LEFT_PAREN field=identifier FROM (DATE | TIMESTAMP)?
@@ -454,7 +454,7 @@ constant
     | type=(DATE | DATEV1 | DATEV2 | TIMESTAMP) STRING_LITERAL                 
                #typeConstructor
     | number                                                                   
                #numericLiteral
     | booleanValue                                                             
                #booleanLiteral
-    | STRING_LITERAL                                                           
                #stringLiteral
+    | BINARY? STRING_LITERAL                                                   
                #stringLiteral
     ;
 
 comparisonOperator
@@ -570,6 +570,7 @@ nonReserved
     | ARRAY
     | AT
     | AUTHORS
+    | AUTO_INCREMENT
     | BACKENDS
     | BACKUP
     | BEGIN
@@ -749,6 +750,7 @@ nonReserved
     | PASSWORD_HISTORY
     | PASSWORD_LOCK_TIME
     | PASSWORD_REUSE
+    | PARTITIONS
     | PATH
     | PAUSE
     | PERCENT
@@ -842,4 +844,4 @@ nonReserved
     | WORK
     | YEAR
 //--DEFAULT-NON-RESERVED-END
-    ;
\ No newline at end of file
+    ;
diff --git a/fe/fe-core/src/main/cup/sql_parser.cup 
b/fe/fe-core/src/main/cup/sql_parser.cup
index 3cd8b66b543..48ddcbb514a 100644
--- a/fe/fe-core/src/main/cup/sql_parser.cup
+++ b/fe/fe-core/src/main/cup/sql_parser.cup
@@ -4519,7 +4519,7 @@ cancel_param ::=
 
 // Delete stmt
 delete_stmt ::=
-    KW_DELETE KW_FROM table_name:table opt_table_alias:alias 
opt_partition_names:partitionNames opt_using_clause:fromClause 
where_clause:wherePredicate
+    KW_DELETE KW_FROM table_name:table opt_partition_names:partitionNames 
opt_table_alias:alias opt_using_clause:fromClause where_clause:wherePredicate
     {:
         RESULT = new DeleteStmt(new TableRef(table, alias), partitionNames, 
fromClause, wherePredicate);
     :}
@@ -7406,6 +7406,8 @@ keyword ::=
     {: RESULT = id; :}
     | KW_ARRAY:id
     {: RESULT = id; :}
+    | KW_AUTO_INCREMENT:id
+    {: RESULT = id; :}
     | KW_BACKUP:id
     {: RESULT = id; :}
     | KW_BEGIN:id
@@ -7630,6 +7632,8 @@ keyword ::=
     {: RESULT = id; :}
     | KW_PARAMETER:id
     {: RESULT = id; :}
+    | KW_PARTITIONS:id
+    {: RESULT = id; :}
     | KW_PASSWORD:id
     {: RESULT = id; :}
     | KW_PASSWORD_EXPIRE:id
diff --git 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
index 1c11e74fcc8..247a24679a1 100644
--- 
a/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
+++ 
b/fe/fe-core/src/test/java/org/apache/doris/nereids/parser/NereidsParserTest.java
@@ -388,4 +388,19 @@ public class NereidsParserTest extends ParserTestBase {
         Assertions.assertEquals(4, 
logicalPlan.getExpressions().get(0).getDepth());
         Assertions.assertEquals(3, 
logicalPlan.getExpressions().get(0).getWidth());
     }
+
+    @Test
+    public void testParseBinaryKeyword() {
+        String sql = "SELECT BINARY 'abc' FROM t";
+        NereidsParser nereidsParser = new NereidsParser();
+        nereidsParser.parseSingle(sql);
+    }
+
+    @Test
+    public void testParseReserveKeyword() {
+        // partitions and auto_increment are reserve keywords
+        String sql = "SELECT BINARY 'abc' FROM information_schema.partitions 
order by AUTO_INCREMENT";
+        NereidsParser nereidsParser = new NereidsParser();
+        nereidsParser.parseSingle(sql);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to