You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/07/10 07:38:17 UTC

[iotdb] branch rel/1.1 updated: [To rel/1.1] Update keywords in IdentifierParser.g4

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

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


The following commit(s) were added to refs/heads/rel/1.1 by this push:
     new 7d16b5b8551 [To rel/1.1] Update keywords in IdentifierParser.g4
7d16b5b8551 is described below

commit 7d16b5b8551d341ad5440be4afbe6118070cd647
Author: Liao Lanyu <14...@qq.com>
AuthorDate: Mon Jul 10 15:38:11 2023 +0800

    [To rel/1.1] Update keywords in IdentifierParser.g4
---
 .../org/apache/iotdb/db/qp/sql/IdentifierParser.g4     | 18 ++++++++++++++++--
 .../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4       | 17 +++++++++++++----
 .../main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 | 14 +++++++++++++-
 .../org/apache/iotdb/commons/path/PartialPathTest.java | 12 ------------
 .../apache/iotdb/db/mpp/plan/parser/ASTVisitor.java    | 12 ++++++------
 5 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4
index a42ad648f01..a82da138e68 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IdentifierParser.g4
@@ -58,10 +58,11 @@ keyWords
     | CONDITION
     | CONFIGNODES
     | CONFIGURATION
+    | CONNECTOR
+    | CONTAIN
     | CONTAINS
     | CONTINUOUS
     | COUNT
-    | CONTAIN
     | CQ
     | CQS
     | CREATE
@@ -75,10 +76,10 @@ keyWords
     | DELETE
     | DESC
     | DESCRIBE
+    | DETAILS
     | DEVICE
     | DEVICEID
     | DEVICES
-    | DETAILS
     | DISABLE
     | DISCARD
     | DROP
@@ -87,8 +88,11 @@ keyWords
     | ENDTIME
     | EVERY
     | EXPLAIN
+    | EXTRACTOR
+    | FALSE
     | FILL
     | FILE
+    | FIRST
     | FLUSH
     | FOR
     | FROM
@@ -118,11 +122,15 @@ keyWords
     | LOCK
     | MERGE
     | METADATA
+    | MIGRATE
+    | NAN
+    | NODEID
     | NODES
     | NONE
     | NOT
     | NOW
     | NULL
+    | NULLS
     | OF
     | OFF
     | OFFSET
@@ -143,6 +151,7 @@ keyWords
     | PREVIOUSUNTILLAST
     | PRIVILEGES
     | PROCESSLIST
+    | PROCESSOR
     | PROPERTY
     | PRUNE
     | QUERIES
@@ -183,6 +192,7 @@ keyWords
     | TEMPLATE
     | TIMEOUT
     | TIMESERIES
+    | TIMEPARTITION
     | TIMESLOTID
     | TO
     | TOLERANCE
@@ -190,6 +200,7 @@ keyWords
     | TRACING
     | TRIGGER
     | TRIGGERS
+    | TRUE
     | TTL
     | UNLINK
     | UNLOAD
@@ -197,12 +208,15 @@ keyWords
     | UPDATE
     | UPSERT
     | URI
+    | USED
     | USER
     | USING
     | VALUES
+    | VARIABLES
     | VARIATION
     | VERIFY
     | VERSION
+    | WATERMARK_EMBEDDING
     | WHERE
     | WITH
     | WITHOUT
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index 16cd477cbe5..3e66c8adf18 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -704,7 +704,7 @@ fullMerge
 
 // Flush
 flush
-    : FLUSH prefixPath? (COMMA prefixPath)* BOOLEAN_LITERAL? (ON (LOCAL | CLUSTER))?
+    : FLUSH prefixPath? (COMMA prefixPath)* boolean_literal? (ON (LOCAL | CLUSTER))?
     ;
 
 // Clear Cache
@@ -792,7 +792,7 @@ loadFileAttributeClauses
 
 loadFileAttributeClause
     : SGLEVEL operator_eq INTEGER_LITERAL
-    | VERIFY operator_eq BOOLEAN_LITERAL
+    | VERIFY operator_eq boolean_literal
     | ONSUCCESS operator_eq (DELETE|NONE)
     ;
 
@@ -916,9 +916,9 @@ constant
     | (MINUS|PLUS)? realLiteral
     | (MINUS|PLUS)? INTEGER_LITERAL
     | STRING_LITERAL
-    | BOOLEAN_LITERAL
+    | boolean_literal
     | null_literal
-    | NAN_LITERAL
+    | nan_literal
     ;
 
 datetimeLiteral
@@ -1003,6 +1003,15 @@ null_literal
     : NULL
     ;
 
+nan_literal
+    : NAN
+    ;
+
+boolean_literal
+    : TRUE
+    | FALSE
+    ;
+
 // Attribute Clause
 
 attributeClauses
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index b4b8fd493a7..489455c2df8 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -262,6 +262,10 @@ EXPLAIN
     : E X P L A I N
     ;
 
+FALSE
+    : F A L S E
+    ;
+
 FILL
     : F I L L
     ;
@@ -390,6 +394,10 @@ MIGRATE
     : M I G R A T E
     ;
 
+NAN
+    : N A N
+    ;
+
 NODEID
     : N O D E I D
     ;
@@ -406,7 +414,6 @@ NOT
     : N O T
     ;
 
-
 NOW
     : N O W
     ;
@@ -703,6 +710,10 @@ TRIGGERS
     : T R I G G E R S
     ;
 
+TRUE
+    : T R U E
+    ;
+
 TTL
     : T T L
     ;
@@ -1063,6 +1074,7 @@ NAN_LITERAL
     : N A N
     ;
 
+
 /**
  * 6. ID
  */
diff --git a/node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java b/node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java
index 621e91af17b..33f37094a7c 100644
--- a/node-commons/src/test/java/org/apache/iotdb/commons/path/PartialPathTest.java
+++ b/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();
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
index 16422081f1a..0408e655f07 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/parser/ASTVisitor.java
@@ -1319,7 +1319,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));
@@ -1509,7 +1509,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(
@@ -2454,7 +2454,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;
@@ -2469,7 +2469,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));
@@ -2611,8 +2611,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");