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

jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 0aca44be528 Update the keywords in IdentifierParser.g4
0aca44be528 is described below

commit 0aca44be528c8e9bb8f47aba22190ec9b7fe63a4
Author: Liao Lanyu <[email protected]>
AuthorDate: Mon Jul 10 08:42:23 2023 +0800

    Update the keywords in IdentifierParser.g4
---
 .../org/apache/iotdb/db/qp/sql/IdentifierParser.g4 | 19 +++++++++++--
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4   | 19 +++++++++----
 .../antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4  | 31 +++++++++-------------
 .../db/queryengine/plan/parser/ASTVisitor.java     | 12 ++++-----
 .../apache/iotdb/commons/path/PartialPathTest.java | 12 ---------
 5 files changed, 49 insertions(+), 44 deletions(-)

diff --git 
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4
 
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4
index 9ddd18c3366..c9e5a54a8e3 100644
--- 
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4
+++ 
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4
@@ -52,6 +52,7 @@ keyWords
     | BOUNDARY
     | BY
     | CACHE
+    | CASE
     | CAST
     | CHILD
     | CLEAR
@@ -60,10 +61,11 @@ keyWords
     | CONDITION
     | CONFIGNODES
     | CONFIGURATION
+    | CONNECTOR
+    | CONTAIN
     | CONTAINS
     | CONTINUOUS
     | COUNT
-    | CONTAIN
     | CQ
     | CQS
     | CREATE
@@ -77,10 +79,10 @@ keyWords
     | DELETE
     | DESC
     | DESCRIBE
+    | DETAILS
     | DEVICE
     | DEVICEID
     | DEVICES
-    | DETAILS
     | DISABLE
     | DISCARD
     | DROP
@@ -90,8 +92,11 @@ keyWords
     | ENDTIME
     | EVERY
     | EXPLAIN
+    | EXTRACTOR
+    | FALSE
     | FILL
     | FILE
+    | FIRST
     | FLUSH
     | FOR
     | FROM
@@ -121,13 +126,17 @@ keyWords
     | LOCK
     | MERGE
     | METADATA
+    | MIGRATE
     | MODEL
     | MODELS
+    | NAN
+    | NODEID
     | NODES
     | NONE
     | NOT
     | NOW
     | NULL
+    | NULLS
     | OF
     | OFF
     | OFFSET
@@ -151,6 +160,7 @@ keyWords
     | PRIVILEGES
     | PRIVILEGE_VALUE
     | PROCESSLIST
+    | PROCESSOR
     | PROPERTY
     | PRUNE
     | QUERIES
@@ -198,6 +208,7 @@ keyWords
     | THROTTLE
     | TIMEOUT
     | TIMESERIES
+    | TIMEPARTITION
     | TIMESLOTID
     | TO
     | TOLERANCE
@@ -206,6 +217,7 @@ keyWords
     | TRAILS
     | TRIGGER
     | TRIGGERS
+    | TRUE
     | TTL
     | UNLINK
     | UNLOAD
@@ -213,13 +225,16 @@ keyWords
     | UPDATE
     | UPSERT
     | URI
+    | USED
     | USER
     | USING
     | VALUES
+    | VARIABLES
     | VARIATION
     | VERIFY
     | VERSION
     | VIEW
+    | WATERMARK_EMBEDDING
     | WHEN
     | WHERE
     | WITH
diff --git 
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index 4158a2a5e4e..1e04b4646a1 100644
--- 
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ 
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -935,7 +935,7 @@ fullMerge
 
 // Flush
 flush
-    : FLUSH prefixPath? (COMMA prefixPath)* BOOLEAN_LITERAL? (ON (LOCAL | 
CLUSTER))?
+    : FLUSH prefixPath? (COMMA prefixPath)* boolean_literal? (ON (LOCAL | 
CLUSTER))?
     ;
 
 // Clear Cache
@@ -1023,7 +1023,7 @@ loadFileAttributeClauses
 
 loadFileAttributeClause
     : SGLEVEL operator_eq INTEGER_LITERAL
-    | VERIFY operator_eq BOOLEAN_LITERAL
+    | VERIFY operator_eq boolean_literal
     | ONSUCCESS operator_eq (DELETE|NONE)
     ;
 
@@ -1101,9 +1101,9 @@ constant
     | (MINUS|PLUS|DIV)? realLiteral
     | (MINUS|PLUS|DIV)? INTEGER_LITERAL
     | STRING_LITERAL
-    | BOOLEAN_LITERAL
+    | boolean_literal
     | null_literal
-    | NAN_LITERAL
+    | nan_literal
     ;
 
 datetimeLiteral
@@ -1135,10 +1135,10 @@ expression
     : LR_BRACKET unaryInBracket=expression RR_BRACKET
     | constant
     | time=(TIME | TIMESTAMP)
+    | caseWhenThenExpression
     | fullPathInExpression
     | scalarFunctionExpression
     | functionName LR_BRACKET expression (COMMA expression)* RR_BRACKET
-    | caseWhenThenExpression
     | (PLUS | MINUS | operator_not) expressionAfterUnaryOperator=expression
     | leftExpression=expression (STAR | DIV | MOD) rightExpression=expression
     | leftExpression=expression (PLUS | MINUS) rightExpression=expression
@@ -1201,6 +1201,15 @@ null_literal
     : NULL
     ;
 
+nan_literal
+    : NAN
+    ;
+
+boolean_literal
+    : TRUE
+    | FALSE
+    ;
+
 // Attribute Clause
 
 attributeClauses
diff --git 
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index 6f58ccf8ad7..936f4bb3c17 100644
--- a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -270,6 +270,10 @@ EXTRACTOR
     : E X T R A C T O R
     ;
 
+FALSE
+    : F A L S E
+    ;
+
 FILL
     : F I L L
     ;
@@ -410,6 +414,10 @@ MODELS
     : M O D E L S
     ;
 
+NAN
+    : N A N
+    ;
+
 NODEID
     : N O D E I D
     ;
@@ -426,7 +434,6 @@ NOT
     : N O T
     ;
 
-
 NOW
     : N O W
     ;
@@ -771,6 +778,10 @@ TRIGGERS
     : T R I G G E R S
     ;
 
+TRUE
+    : T R U E
+    ;
+
 TTL
     : T T L
     ;
@@ -1194,24 +1205,6 @@ fragment DEC_DIGIT
     ;
 
 
-// Boolean Literal
-
-BOOLEAN_LITERAL
-       : T R U E
-       | F A L S E
-       ;
-
-
-// Other Literals
-
-NULL_LITERAL
-    : NULL
-    ;
-
-NAN_LITERAL
-    : N A N
-    ;
-
 /**
  * 6. ID
  */
diff --git 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
index 9956857d964..2e0600d3fb0 100644
--- 
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+++ 
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -1698,7 +1698,7 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
 
   private Literal parseLiteral(ConstantContext constantContext) {
     String text = constantContext.getText();
-    if (constantContext.BOOLEAN_LITERAL() != null) {
+    if (constantContext.boolean_literal() != null) {
       return new BooleanLiteral(text);
     } else if (constantContext.STRING_LITERAL() != null) {
       return new StringLiteral(parseStringLiteral(text));
@@ -1889,7 +1889,7 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
     } else if (ctx.SGLEVEL() != null) {
       
loadTsFileStatement.setSgLevel(Integer.parseInt(ctx.INTEGER_LITERAL().getText()));
     } else if (ctx.VERIFY() != null) {
-      
loadTsFileStatement.setVerifySchema(Boolean.parseBoolean(ctx.BOOLEAN_LITERAL().getText()));
+      
loadTsFileStatement.setVerifySchema(Boolean.parseBoolean(ctx.boolean_literal().getText()));
     } else {
       throw new SemanticException(
           String.format(
@@ -2923,7 +2923,7 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
 
   private String parseConstant(ConstantContext constantContext) {
     String text = constantContext.getText();
-    if (constantContext.BOOLEAN_LITERAL() != null
+    if (constantContext.boolean_literal() != null
         || constantContext.INTEGER_LITERAL() != null
         || constantContext.realLiteral() != null) {
       return text;
@@ -2938,7 +2938,7 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
 
   private Expression parseConstantOperand(ConstantContext constantContext) {
     String text = constantContext.getText();
-    if (constantContext.BOOLEAN_LITERAL() != null) {
+    if (constantContext.boolean_literal() != null) {
       return new ConstantOperand(TSDataType.BOOLEAN, text);
     } else if (constantContext.STRING_LITERAL() != null) {
       return new ConstantOperand(TSDataType.TEXT, parseStringLiteral(text));
@@ -3092,8 +3092,8 @@ public class ASTVisitor extends 
IoTDBSqlParserBaseVisitor<Statement> {
   public Statement visitFlush(IoTDBSqlParser.FlushContext ctx) {
     FlushStatement flushStatement = new FlushStatement(StatementType.FLUSH);
     List<PartialPath> storageGroups = null;
-    if (ctx.BOOLEAN_LITERAL() != null) {
-      
flushStatement.setSeq(Boolean.parseBoolean(ctx.BOOLEAN_LITERAL().getText()));
+    if (ctx.boolean_literal() != null) {
+      
flushStatement.setSeq(Boolean.parseBoolean(ctx.boolean_literal().getText()));
     }
     if (ctx.CLUSTER() != null && 
!IoTDBDescriptor.getInstance().getConfig().isClusterMode()) {
       throw new SemanticException("FLUSH ON CLUSTER is not supported in 
standalone mode");
diff --git 
a/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java
 
b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java
index a6ae9114762..8874c34fd4e 100644
--- 
a/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java
+++ 
b/iotdb-core/node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java
@@ -174,12 +174,6 @@ public class PartialPathTest {
     } catch (IllegalPathException ignored) {
     }
 
-    try {
-      new PartialPath("root.sg.watermark_embedding");
-      fail();
-    } catch (IllegalPathException ignored) {
-    }
-
     try {
       new PartialPath("root.sg.time");
       fail();
@@ -341,12 +335,6 @@ public class PartialPathTest {
     } catch (IllegalPathException ignored) {
     }
 
-    try {
-      new PartialPath("root.sg", "watermark_embedding");
-      fail();
-    } catch (IllegalPathException ignored) {
-    }
-
     try {
       new PartialPath("root.sg.d1", "root");
       fail();

Reply via email to