You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by GitBox <gi...@apache.org> on 2021/05/20 08:45:53 UTC

[GitHub] [iotdb] yanhongwangg opened a new pull request #3240: support “all” keyword when execute fill query

yanhongwangg opened a new pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240


   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] yanhongwangg commented on pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
yanhongwangg commented on pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240#issuecomment-847478027


   > Please merge the newest master codes and rerun the CI again~
   
   I get it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] yanhongwangg commented on a change in pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
yanhongwangg commented on a change in pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240#discussion_r637653354



##########
File path: server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
##########
@@ -1351,12 +1351,47 @@ public void parseFillClause(FillClauseContext ctx, QueryOperator queryOp) {
     List<TypeClauseContext> list = ctx.typeClause();
     Map<TSDataType, IFill> fillTypes = new EnumMap<>(TSDataType.class);
     for (TypeClauseContext typeClause : list) {
-      parseTypeClause(typeClause, fillTypes);
+      if (typeClause.ALL() != null) {
+        if (typeClause.linearClause() != null) {
+          throw new SQLParserException("fill all doesn't support linear fill");
+        }
+        parseAllTypeClause(typeClause, fillTypes);
+        break;
+      } else {
+        parsePrimitiveTypeClause(typeClause, fillTypes);
+      }
     }
     queryOp.setFill(true);
     queryOp.setFillTypes(fillTypes);
   }
 
+  private void parseAllTypeClause(TypeClauseContext ctx, Map<TSDataType, IFill> fillTypes) {
+    IFill fill;
+    if (ctx.previousUntilLastClause() != null) {
+      long preRange;
+      if (ctx.previousUntilLastClause().DURATION() != null) {
+        preRange =
+            DatetimeUtils.convertDurationStrToLong(
+                ctx.previousUntilLastClause().DURATION().getText());
+      } else {
+        preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+      }
+      fill = new PreviousFill(preRange, true);
+    } else {
+      long preRange;

Review comment:
       Thank you for your comments, I will make changes accordingly




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] neuyilan merged pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
neuyilan merged pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] neuyilan commented on a change in pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
neuyilan commented on a change in pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240#discussion_r636584847



##########
File path: server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
##########
@@ -1351,7 +1351,39 @@ public void parseFillClause(FillClauseContext ctx, QueryOperator queryOp) {
     List<TypeClauseContext> list = ctx.typeClause();
     Map<TSDataType, IFill> fillTypes = new EnumMap<>(TSDataType.class);
     for (TypeClauseContext typeClause : list) {
-      parseTypeClause(typeClause, fillTypes);
+      if (typeClause.ALL() != null) {
+        if (typeClause.linearClause() != null) {
+          throw new SQLParserException("fill all doesn't support linear fill");
+        }
+        IFill fill;
+        if (typeClause.previousUntilLastClause() != null) {
+          long preRange;
+          if (typeClause.previousUntilLastClause().DURATION() != null) {
+            preRange =
+                DatetimeUtils.convertDurationStrToLong(
+                    typeClause.previousUntilLastClause().DURATION().getText());
+          } else {
+            preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+          }
+          fill = new PreviousFill(preRange, true);
+        } else {
+          long preRange;
+          if (typeClause.previousClause().DURATION() != null) {
+            preRange =
+                DatetimeUtils.convertDurationStrToLong(
+                    typeClause.previousClause().DURATION().getText());
+          } else {
+            preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+          }
+          fill = new PreviousFill(preRange);
+        }
+        for (TSDataType tsDataType : TSDataType.values()) {
+          fillTypes.put(tsDataType, fill.copy());
+        }
+        break;
+      } else {
+        parseTypeClause(typeClause, fillTypes);
+      }

Review comment:
       LGTM, but in terms of code readability, I have the following suggestions:
   In fact, All the code in this section is used for `parseTypeClause()`, so it may be better to extract a public method called `parseTypeClause()`. For type all, it can be extracted as a `private parseAllTypeClause ()`, The origin `parseTypeClause()` method  can be changed to private `parsePrimitiveTypeClause()`.
   What's your opinion?
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] neuyilan commented on pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
neuyilan commented on pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240#issuecomment-847465143


   Please merge the newest master codes and rerun the CI again~


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] yanhongwangg commented on a change in pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
yanhongwangg commented on a change in pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240#discussion_r636743115



##########
File path: server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
##########
@@ -1351,7 +1351,39 @@ public void parseFillClause(FillClauseContext ctx, QueryOperator queryOp) {
     List<TypeClauseContext> list = ctx.typeClause();
     Map<TSDataType, IFill> fillTypes = new EnumMap<>(TSDataType.class);
     for (TypeClauseContext typeClause : list) {
-      parseTypeClause(typeClause, fillTypes);
+      if (typeClause.ALL() != null) {
+        if (typeClause.linearClause() != null) {
+          throw new SQLParserException("fill all doesn't support linear fill");
+        }
+        IFill fill;
+        if (typeClause.previousUntilLastClause() != null) {
+          long preRange;
+          if (typeClause.previousUntilLastClause().DURATION() != null) {
+            preRange =
+                DatetimeUtils.convertDurationStrToLong(
+                    typeClause.previousUntilLastClause().DURATION().getText());
+          } else {
+            preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+          }
+          fill = new PreviousFill(preRange, true);
+        } else {
+          long preRange;
+          if (typeClause.previousClause().DURATION() != null) {
+            preRange =
+                DatetimeUtils.convertDurationStrToLong(
+                    typeClause.previousClause().DURATION().getText());
+          } else {
+            preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+          }
+          fill = new PreviousFill(preRange);
+        }
+        for (TSDataType tsDataType : TSDataType.values()) {
+          fillTypes.put(tsDataType, fill.copy());
+        }
+        break;
+      } else {
+        parseTypeClause(typeClause, fillTypes);
+      }

Review comment:
       I agree with you




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] Alima777 commented on a change in pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
Alima777 commented on a change in pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240#discussion_r637344878



##########
File path: session/src/test/java/org/apache/iotdb/session/IoTDBSessionSimpleIT.java
##########
@@ -546,6 +547,93 @@ public void testInsertOneDeviceRecords()
     session.close();
   }
 
+  @Test
+  public void testFillAll() throws IoTDBConnectionException, StatementExecutionException {
+    session = new Session("127.0.0.1", 6667, "root", "root");
+    session.open();
+    List<String> paths = new ArrayList<>();
+    paths.add("root.sg.d.s1");
+    paths.add("root.sg.d.s2");
+    paths.add("root.sg.d.s3");
+    paths.add("root.sg.d.s4");
+    paths.add("root.sg.d.s5");
+    paths.add("root.sg.d.s6");
+    List<TSDataType> tsDataTypes = new ArrayList<>();
+    tsDataTypes.add(TSDataType.BOOLEAN);
+    tsDataTypes.add(TSDataType.INT32);
+    tsDataTypes.add(TSDataType.INT64);
+    tsDataTypes.add(TSDataType.FLOAT);
+    tsDataTypes.add(TSDataType.DOUBLE);
+    tsDataTypes.add(TSDataType.TEXT);
+    List<TSEncoding> tsEncodings = new ArrayList<>();
+    tsEncodings.add(TSEncoding.RLE);
+    tsEncodings.add(TSEncoding.RLE);
+    tsEncodings.add(TSEncoding.RLE);
+    tsEncodings.add(TSEncoding.RLE);
+    tsEncodings.add(TSEncoding.RLE);
+    tsEncodings.add(TSEncoding.PLAIN);
+    List<CompressionType> compressionTypes = new ArrayList<>();
+    compressionTypes.add(CompressionType.SNAPPY);
+    compressionTypes.add(CompressionType.SNAPPY);
+    compressionTypes.add(CompressionType.SNAPPY);
+    compressionTypes.add(CompressionType.SNAPPY);
+    compressionTypes.add(CompressionType.SNAPPY);
+    compressionTypes.add(CompressionType.SNAPPY);
+    session.createMultiTimeseries(
+        paths, tsDataTypes, tsEncodings, compressionTypes, null, null, null, null);
+
+    List<String> measurements = new ArrayList<>();
+    measurements.add("s1");
+    measurements.add("s2");
+    measurements.add("s3");
+    measurements.add("s4");
+    measurements.add("s5");
+    measurements.add("s6");
+    List<Object> startValues = new ArrayList<>();
+    startValues.add(false);
+    startValues.add(1);
+    startValues.add((long) 1);
+    startValues.add((float) 1.0);
+    startValues.add(1.0);
+    startValues.add("1");
+    session.insertRecord("root.sg.d", 1, measurements, tsDataTypes, startValues);
+
+    List<Object> endValues = new ArrayList<>();
+    endValues.add(true);
+    endValues.add(100);
+    endValues.add((long) 100);
+    endValues.add((float) 100.0);
+    endValues.add(100.0);
+    endValues.add("100");

Review comment:
       EndValue is never used?

##########
File path: server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
##########
@@ -1351,12 +1351,47 @@ public void parseFillClause(FillClauseContext ctx, QueryOperator queryOp) {
     List<TypeClauseContext> list = ctx.typeClause();
     Map<TSDataType, IFill> fillTypes = new EnumMap<>(TSDataType.class);
     for (TypeClauseContext typeClause : list) {
-      parseTypeClause(typeClause, fillTypes);
+      if (typeClause.ALL() != null) {
+        if (typeClause.linearClause() != null) {
+          throw new SQLParserException("fill all doesn't support linear fill");
+        }
+        parseAllTypeClause(typeClause, fillTypes);
+        break;
+      } else {
+        parsePrimitiveTypeClause(typeClause, fillTypes);
+      }
     }
     queryOp.setFill(true);
     queryOp.setFillTypes(fillTypes);
   }
 
+  private void parseAllTypeClause(TypeClauseContext ctx, Map<TSDataType, IFill> fillTypes) {
+    IFill fill;
+    if (ctx.previousUntilLastClause() != null) {
+      long preRange;
+      if (ctx.previousUntilLastClause().DURATION() != null) {
+        preRange =
+            DatetimeUtils.convertDurationStrToLong(
+                ctx.previousUntilLastClause().DURATION().getText());
+      } else {
+        preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+      }
+      fill = new PreviousFill(preRange, true);
+    } else {
+      long preRange;

Review comment:
       `preRange` can be moved to outside of this if.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [iotdb] neuyilan commented on a change in pull request #3240: support “all” keyword when execute fill query

Posted by GitBox <gi...@apache.org>.
neuyilan commented on a change in pull request #3240:
URL: https://github.com/apache/iotdb/pull/3240#discussion_r636584847



##########
File path: server/src/main/java/org/apache/iotdb/db/qp/sql/IoTDBSqlVisitor.java
##########
@@ -1351,7 +1351,39 @@ public void parseFillClause(FillClauseContext ctx, QueryOperator queryOp) {
     List<TypeClauseContext> list = ctx.typeClause();
     Map<TSDataType, IFill> fillTypes = new EnumMap<>(TSDataType.class);
     for (TypeClauseContext typeClause : list) {
-      parseTypeClause(typeClause, fillTypes);
+      if (typeClause.ALL() != null) {
+        if (typeClause.linearClause() != null) {
+          throw new SQLParserException("fill all doesn't support linear fill");
+        }
+        IFill fill;
+        if (typeClause.previousUntilLastClause() != null) {
+          long preRange;
+          if (typeClause.previousUntilLastClause().DURATION() != null) {
+            preRange =
+                DatetimeUtils.convertDurationStrToLong(
+                    typeClause.previousUntilLastClause().DURATION().getText());
+          } else {
+            preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+          }
+          fill = new PreviousFill(preRange, true);
+        } else {
+          long preRange;
+          if (typeClause.previousClause().DURATION() != null) {
+            preRange =
+                DatetimeUtils.convertDurationStrToLong(
+                    typeClause.previousClause().DURATION().getText());
+          } else {
+            preRange = IoTDBDescriptor.getInstance().getConfig().getDefaultFillInterval();
+          }
+          fill = new PreviousFill(preRange);
+        }
+        for (TSDataType tsDataType : TSDataType.values()) {
+          fillTypes.put(tsDataType, fill.copy());
+        }
+        break;
+      } else {
+        parseTypeClause(typeClause, fillTypes);
+      }

Review comment:
       LGTM, but in terms of code readability, I have the following suggestions:
   In fact, All the code in this section is used for `parseTypeClause()`, so it may be better to extract a public method called `parseTypeClause()`. For type `ALL`, it can be extracted as a `private parseAllTypeClause ()`, The origin `parseTypeClause()` method  can be changed to private `parsePrimitiveTypeClause()`.
   What's your opinion?
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org