You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2021/08/17 06:22:00 UTC

[iotdb] branch master updated: [IOTDB-1561] Fix problems caused by keywords (#3756) (#3761)

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

rong 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 ff20e38  [IOTDB-1561] Fix problems caused by keywords (#3756) (#3761)
ff20e38 is described below

commit ff20e384d9447782d85bcc288cd8e289c81197c1
Author: Hang Ji <55...@users.noreply.github.com>
AuthorDate: Tue Aug 17 14:21:38 2021 +0800

    [IOTDB-1561] Fix problems caused by keywords (#3756) (#3761)
---
 antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4    | 10 +++-------
 .../IoTDB-SQL-Language/DML-Data-Manipulation-Language.md       |  4 ++--
 .../IoTDB-SQL-Language/DML-Data-Manipulation-Language.md       |  4 ++--
 .../main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java  |  7 ++++---
 .../test/java/org/apache/iotdb/db/integration/IoTDBFillIT.java |  2 +-
 5 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
index d697dec..5b40fdb 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlBase.g4
@@ -312,7 +312,7 @@ groupByLevelClause
 typeClause
     : (dataType | ALL) LS_BRACKET linearClause RS_BRACKET
     | (dataType | ALL) LS_BRACKET previousClause RS_BRACKET
-    | (dataType | ALL) LS_BRACKET valueClause RS_BRACKET
+    | (dataType | ALL) LS_BRACKET specificValueClause RS_BRACKET
     | (dataType | ALL) LS_BRACKET previousUntilLastClause RS_BRACKET
     ;
 
@@ -324,8 +324,8 @@ previousClause
     : PREVIOUS (COMMA DURATION)?
     ;
 
-valueClause
-    : VALUE (COMMA constant)?
+specificValueClause
+    : constant?
     ;
 
 previousUntilLastClause
@@ -823,10 +823,6 @@ LINEAR
     : L I N E A R
     ;
 
-VALUE
-    : V A L U E
-    ;
-
 PREVIOUS
     : P R E V I O U S
     ;
diff --git a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index 8548cd0..75a33ff 100644
--- a/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -1037,7 +1037,7 @@ It costs 0.017s
 When the value of the queried timestamp is null, given fill value is used to fill the blank. The formalized value method is as follows:
 
 ```
-select <path> from <prefixPath> where time = <T> fill(<data_type>[value, constant]…)
+select <path> from <prefixPath> where time = <T> fill(<data_type>[constant]…)
 ```
 Detailed descriptions of all parameters are given in Table 3-6.
 
@@ -1056,7 +1056,7 @@ Detailed descriptions of all parameters are given in Table 3-6.
 Here we give an example of filling null values using the value method. The SQL statement is as follows:
 
 ```
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [value, 2.0])
+select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [2.0])
 ```
 which means:
 
diff --git a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
index 8a8bae7..6a7b5d1 100644
--- a/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
+++ b/docs/zh/UserGuide/IoTDB-SQL-Language/DML-Data-Manipulation-Language.md
@@ -815,7 +815,7 @@ It costs 0.017s
 当查询的时间戳值为空时,将使用给定的值来填充空白。 特定值填充方法如下:
 
 ```
-select <path> from <prefixPath> where time = <T> fill(<data_type>[value, constant]…)
+select <path> from <prefixPath> where time = <T> fill(<data_type>[constant]…)
 ```
 
 表3-6中给出了所有参数的详细说明。
@@ -837,7 +837,7 @@ select <path> from <prefixPath> where time = <T> fill(<data_type>[value, constan
 在这里,我们举一个使用特定值方法填充空值的示例。 SQL语句如下:
 
 ```
-select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [value, 2.0])
+select temperature from root.sgcc.wf03.wt01 where time = 2017-11-01T16:37:50.000 fill(float [2.0])
 ```
 
 意思是:
diff --git a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
index 99be5ca..0389581 100644
--- a/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
@@ -1823,9 +1823,10 @@ public class IoTDBSqlVisitor extends SqlBaseBaseVisitor<Operator> {
       } else {
         fillTypes.put(dataType, new PreviousFill(defaultFillInterval));
       }
-    } else if (ctx.valueClause() != null) {
-      if (ctx.valueClause().constant() != null) {
-        fillTypes.put(dataType, new ValueFill(ctx.valueClause().constant().getText(), dataType));
+    } else if (ctx.specificValueClause() != null) {
+      if (ctx.specificValueClause().constant() != null) {
+        fillTypes.put(
+            dataType, new ValueFill(ctx.specificValueClause().constant().getText(), dataType));
       } else {
         throw new SQLParserException("fill value cannot be null");
       }
diff --git a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBFillIT.java b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBFillIT.java
index 45aabaa..ec527dc 100644
--- a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBFillIT.java
+++ b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBFillIT.java
@@ -322,7 +322,7 @@ public class IoTDBFillIT {
           statement.execute(
               "select temperature,status, hardware "
                   + "from root.ln.wf01.wt01 where time = 7 "
-                  + "Fill(int32[value, 7], double[value, 7], boolean[value, true])");
+                  + "Fill(int32[7], double[7], boolean[true])");
 
       Assert.assertTrue(hasResultSet);
       ResultSet resultSet = statement.getResultSet();