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 c7e823ac65..a1eea97161 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 @@ -121,6 +121,7 @@ BEGIN: 'BEGIN'; 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 880986a6ce..a91f207e47 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 @@ -678,7 +678,7 @@ primaryExpression | LEFT_PAREN query RIGHT_PAREN #subqueryExpression | ATSIGN identifierOrText #userVariable | DOUBLEATSIGN (kind=(GLOBAL | SESSION) DOT)? identifier #systemVariable - | identifier #columnReference + | BINARY? identifier #columnReference | base=primaryExpression DOT fieldName=identifier #dereference | LEFT_PAREN expression RIGHT_PAREN #parenthesizedExpression | KEY (dbName=identifier DOT)? keyName=identifier #encryptKey @@ -760,7 +760,7 @@ constant | type=(DATE | DATEV1 | DATEV2 | TIMESTAMP) STRING_LITERAL #typeConstructor | number #numericLiteral | booleanValue #booleanLiteral - | STRING_LITERAL #stringLiteral + | BINARY? STRING_LITERAL #stringLiteral | LEFT_BRACKET (items+=constant)? (COMMA items+=constant)* RIGHT_BRACKET #arrayLiteral | LEFT_BRACE (items+=constant COLON items+=constant)? (COMMA items+=constant COLON items+=constant)* RIGHT_BRACE #mapLiteral @@ -898,6 +898,7 @@ nonReserved | ARRAY | AT | AUTHORS + | AUTO_INCREMENT | BACKENDS | BACKUP | BEGIN @@ -1067,6 +1068,7 @@ nonReserved | PASSWORD_HISTORY | PASSWORD_LOCK_TIME | PASSWORD_REUSE + | PARTITIONS | PATH | PAUSE | PERCENT diff --git a/fe/fe-core/src/main/cup/sql_parser.cup b/fe/fe-core/src/main/cup/sql_parser.cup index 26b221c128..976ad030df 100644 --- a/fe/fe-core/src/main/cup/sql_parser.cup +++ b/fe/fe-core/src/main/cup/sql_parser.cup @@ -7557,6 +7557,8 @@ keyword ::= {: RESULT = id; :} | KW_ARRAY:id {: RESULT = id; :} + | KW_AUTO_INCREMENT:id + {: RESULT = id; :} | KW_BACKUP:id {: RESULT = id; :} | KW_BEGIN:id @@ -7783,6 +7785,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 dc7e336433..6dbcacee40 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 @@ -457,4 +457,19 @@ public class NereidsParserTest extends ParserTestBase { NereidsParser nereidsParser = new NereidsParser(); nereidsParser.parseSingle(sql); } + + @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); + } }