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

[iotdb] branch lmh/fixSelectInto created (now f96e6be0808)

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

hui pushed a change to branch lmh/fixSelectInto
in repository https://gitbox.apache.org/repos/asf/iotdb.git


      at f96e6be0808 add test

This branch includes the following new commits:

     new beccd1a3df7 fix
     new f96e6be0808 add test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[iotdb] 02/02: add test

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hui pushed a commit to branch lmh/fixSelectInto
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit f96e6be08080e69b3928832d29c7ce5bb716b42d
Author: liuminghui233 <54...@qq.com>
AuthorDate: Sun May 7 21:36:11 2023 +0800

    add test
---
 .../iotdb/db/it/selectinto/IoTDBSelectIntoIT.java  | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/selectinto/IoTDBSelectIntoIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/selectinto/IoTDBSelectIntoIT.java
index 3712ce3b9bf..c9d865128f7 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/selectinto/IoTDBSelectIntoIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/selectinto/IoTDBSelectIntoIT.java
@@ -483,6 +483,36 @@ public class IoTDBSelectIntoIT {
         "select k1, k2, k3 from root.sg_abd_expr.*;", expectedQueryHeader, queryRetArray);
   }
 
+  @Test
+  public void testExpressionAlignByDevice2() {
+    String[] intoRetArray =
+        new String[] {
+          "root.sg.d1,avg(s1),root.agg_expr.d1.avg_s1,1,",
+          "root.sg.d1,sum(s1) + sum(s1),root.agg_expr.d1.sum_s1_add_s1,1,",
+          "root.sg.d1,count(s2),root.agg_expr.d1.count_s2,1,",
+          "root.sg.d2,avg(s1),root.agg_expr.d2.avg_s1,1,",
+          "root.sg.d2,sum(s1) + sum(s1),root.agg_expr.d2.sum_s1_add_s1,1,",
+          "root.sg.d2,count(s2),root.agg_expr.d2.count_s2,1,",
+        };
+    resultSetEqualTest(
+        "select avg(s1), sum(s1) + sum(s1), count(s2)"
+            + " into root.agg_expr.${2}(avg_s1, sum_s1_add_s1, count_s2)"
+            + " from root.sg.d1, root.sg.d2 align by device;",
+        selectIntoAlignByDeviceHeader, intoRetArray);
+
+    String expectedQueryHeader =
+        "Time,root.agg_expr.d1.avg_s1,root.agg_expr.d2.avg_s1,root.agg_expr.d1.sum_s1_add_s1,"
+            + "root.agg_expr.d2.sum_s1_add_s1,root.agg_expr.d1.count_s2,root.agg_expr.d2.count_s2,";
+    String[] queryRetArray =
+        new String[] {
+          "0,6.5,6.428571428571429,130.0,90.0,9,8,",
+        };
+    resultSetEqualTest(
+        "select avg_s1, sum_s1_add_s1, count_s2 from root.agg_expr.*;",
+        expectedQueryHeader,
+        queryRetArray);
+  }
+
   // -------------------------------------- CHECK EXCEPTION -------------------------------------
 
   @Test


[iotdb] 01/02: fix

Posted by hu...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hui pushed a commit to branch lmh/fixSelectInto
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit beccd1a3df7d1b1bf5d0fb6033396b089e31a53c
Author: liuminghui233 <54...@qq.com>
AuthorDate: Sun May 7 21:09:18 2023 +0800

    fix
---
 .../db/mpp/execution/operator/process/DeviceViewIntoOperator.java   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewIntoOperator.java b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewIntoOperator.java
index 5f2d2022192..32a0959d80f 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewIntoOperator.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/execution/operator/process/DeviceViewIntoOperator.java
@@ -49,6 +49,7 @@ public class DeviceViewIntoOperator extends AbstractIntoOperator {
   private final Map<String, Boolean> targetDeviceToAlignedMap;
   private final Map<String, List<Pair<String, PartialPath>>> deviceToSourceTargetPathPairListMap;
 
+  private final int deviceColumnIndex;
   private String currentDevice;
 
   private final TsBlockBuilder resultTsBlockBuilder;
@@ -82,6 +83,9 @@ public class DeviceViewIntoOperator extends AbstractIntoOperator {
             .map(ColumnHeader::getColumnType)
             .collect(Collectors.toList());
     this.resultTsBlockBuilder = new TsBlockBuilder(outputDataTypes);
+
+    this.deviceColumnIndex =
+        sourceColumnToInputLocationMap.get(ColumnHeaderConstant.DEVICE).getValueColumnIndex();
   }
 
   @Override
@@ -90,7 +94,7 @@ public class DeviceViewIntoOperator extends AbstractIntoOperator {
       return true;
     }
 
-    String device = String.valueOf(inputTsBlock.getValueColumns()[0].getBinary(0));
+    String device = String.valueOf(inputTsBlock.getValueColumns()[deviceColumnIndex].getBinary(0));
     if (!Objects.equals(device, currentDevice)) {
       InsertMultiTabletsStatement insertMultiTabletsStatement =
           constructInsertMultiTabletsStatement(false);