iotdb-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [iotdb] Alima777 commented on a change in pull request #3240: support “all” keyword when execute fill query
Date Sat, 22 May 2021 03:08:34 GMT

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



Mime
View raw message