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 2022/07/12 09:02:33 UTC

[iotdb] branch lmh/emptySet created (now 1e0741a74e)

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

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


      at 1e0741a74e add some ITs

This branch includes the following new commits:

     new 37cc7a9f01 refactor resultSet format for empty query
     new 1e0741a74e add some ITs

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] 01/02: refactor resultSet format for empty query

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

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

commit 37cc7a9f013eeff65bb7ffafd87ee0e05c0e856d
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Tue Jul 12 16:38:40 2022 +0800

    refactor resultSet format for empty query
---
 .../java/org/apache/iotdb/db/mpp/common/header/DatasetHeader.java   | 2 ++
 .../db/mpp/plan/execution/memory/StatementMemorySourceVisitor.java  | 6 +++++-
 .../src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java  | 4 ++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/common/header/DatasetHeader.java b/server/src/main/java/org/apache/iotdb/db/mpp/common/header/DatasetHeader.java
index 4e270d2365..34680b5a2c 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/common/header/DatasetHeader.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/common/header/DatasetHeader.java
@@ -34,6 +34,8 @@ import java.util.stream.Collectors;
 /** The header of query result dataset. */
 public class DatasetHeader {
 
+  public static DatasetHeader EMPTY_HEADER = new DatasetHeader(new ArrayList<>(), false);
+
   // column names, data types and aliases of result dataset
   private final List<ColumnHeader> columnHeaders;
 
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/memory/StatementMemorySourceVisitor.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/memory/StatementMemorySourceVisitor.java
index 40927caf1a..6e18b82423 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/memory/StatementMemorySourceVisitor.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/memory/StatementMemorySourceVisitor.java
@@ -50,12 +50,16 @@ import java.util.List;
 import java.util.Set;
 import java.util.TreeSet;
 
+import static org.apache.iotdb.db.mpp.common.header.DatasetHeader.EMPTY_HEADER;
+
 public class StatementMemorySourceVisitor
     extends StatementVisitor<StatementMemorySource, StatementMemorySourceContext> {
 
   @Override
   public StatementMemorySource visitNode(StatementNode node, StatementMemorySourceContext context) {
-    return new StatementMemorySource(new TsBlock(0), new DatasetHeader(new ArrayList<>(), false));
+    DatasetHeader datasetHeader = context.getAnalysis().getRespDatasetHeader();
+    return new StatementMemorySource(
+        new TsBlock(0), datasetHeader == null ? EMPTY_HEADER : datasetHeader);
   }
 
   @Override
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
index 3b8d2bd608..68f451ae02 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/QueryDataSetUtils.java
@@ -202,6 +202,10 @@ public class QueryDataSetUtils {
         break;
       }
       TsBlock tsBlock = optionalTsBlock.get();
+      if (tsBlock.isEmpty()) {
+        break;
+      }
+
       int currentCount = tsBlock.getPositionCount();
       // serialize time column
       for (int i = 0; i < currentCount; i++) {


[iotdb] 02/02: add some ITs

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

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

commit 1e0741a74e968a0cf7986452f4a7b92e2d963432
Author: Minghui Liu <li...@foxmail.com>
AuthorDate: Tue Jul 12 17:02:01 2022 +0800

    add some ITs
---
 .../apache/iotdb/db/it/query/IoTDBResultSetIT.java | 29 ++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBResultSetIT.java b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBResultSetIT.java
index 3997852de9..34bf962755 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBResultSetIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBResultSetIT.java
@@ -39,6 +39,7 @@ import java.sql.Statement;
 import java.sql.Types;
 
 import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
@@ -57,6 +58,8 @@ public class IoTDBResultSetIT {
         "insert into root.sg.dev(time,status) values(1,3.14)"
       };
 
+  private static final String[] emptyResultSet = new String[] {};
+
   @BeforeClass
   public static void setUp() throws Exception {
     EnvFactory.getEnv().initBeforeClass();
@@ -128,4 +131,30 @@ public class IoTDBResultSetIT {
       fail(e.getMessage());
     }
   }
+
+  @Test
+  public void emptyQueryTest1() {
+    String expectedHeader = "Time,";
+    resultSetEqualTest("select * from root.sg1.d1", expectedHeader, emptyResultSet);
+  }
+
+  @Test
+  public void emptyQueryTest2() {
+    String expectedHeader =
+        "Time,root.t1.wf01.wt01.status,root.t1.wf01.wt01.temperature,root.t1.wf01.wt01.type,root.t1.wf01.wt01.grade,";
+    resultSetEqualTest("select * from root.t1.wf01.wt01", expectedHeader, emptyResultSet);
+  }
+
+  @Test
+  public void emptyShowTimeseriesTest() {
+    String expectedHeader =
+        "timeseries,alias,storage group,dataType,encoding,compression,tags,attributes,";
+    resultSetEqualTest("show timeseries root.sg1.**", expectedHeader, emptyResultSet);
+  }
+
+  @Test
+  public void emptyShowDeviceTest() {
+    String expectedHeader = "devices,isAligned,";
+    resultSetEqualTest("show devices root.sg1.**", expectedHeader, emptyResultSet);
+  }
 }