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 2020/08/28 09:54:04 UTC

[GitHub] [incubator-iotdb] mychaow commented on a change in pull request #1494: [IOTDB-768] Extend more functions in aggregation by level

mychaow commented on a change in pull request #1494:
URL: https://github.com/apache/incubator-iotdb/pull/1494#discussion_r479047487



##########
File path: server/src/main/java/org/apache/iotdb/db/query/executor/AggregationExecutor.java
##########
@@ -318,28 +318,80 @@ private void aggregateWithValueFilter(List<AggregateResult> aggregateResults,
    * using aggregate result data list construct QueryDataSet.
    *
    * @param aggregateResultList aggregate result list
+   * @throws QueryProcessException 
    */
-  private QueryDataSet constructDataSet(List<AggregateResult> aggregateResultList, RawDataQueryPlan plan) {
+  private QueryDataSet constructDataSet(List<AggregateResult> aggregateResultList, AggregationPlan plan) 
+      throws QueryProcessException {
     RowRecord record = new RowRecord(0);
     for (AggregateResult resultData : aggregateResultList) {
       TSDataType dataType = resultData.getResultDataType();
       record.addField(resultData.getResult(), dataType);
     }
-
     SingleDataSet dataSet = null;
-    if (((AggregationPlan)plan).getLevel() >= 0) {
-      // current only support count operation
+    if (plan.getLevel() >= 0) {
+      if (plan.getAggregations().size() > 1) {
+        //throw new QueryProcessException("Group by level doesn't support multiple aggregations");
+      }
+      // TODO: Check data type here
+      
+      String aggregation = plan.getAggregations().get(0);
+      
       Map<Integer, String> pathIndex = new HashMap<>();
-      Map<String, Long> finalPaths = FilePathUtils.getPathByLevel(plan.getDeduplicatedPaths(), ((AggregationPlan)plan).getLevel(), pathIndex);
-
-      RowRecord curRecord = FilePathUtils.mergeRecordByPath(record, finalPaths, pathIndex);
-
       List<Path> paths = new ArrayList<>();
       List<TSDataType> dataTypes = new ArrayList<>();
-      for (int i = 0; i < finalPaths.size(); i++) {
-        dataTypes.add(TSDataType.INT64);
+      RowRecord curRecord = null;
+      Set<String> finalPaths = FilePathUtils.getPathByLevel(plan, pathIndex);
+      switch (aggregation) {

Review comment:
       you should check the datatype of the data points, sum could be caculated by int and float, but text and boolean should not be supportted




----------------------------------------------------------------
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