You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by xi...@apache.org on 2022/05/03 09:39:18 UTC
[iotdb] branch xingtanzjr/fix_empty_partition updated: fix the scenario that there is no data in corresponding storage group
This is an automated email from the ASF dual-hosted git repository.
xingtanzjr pushed a commit to branch xingtanzjr/fix_empty_partition
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/xingtanzjr/fix_empty_partition by this push:
new d2ea020556 fix the scenario that there is no data in corresponding storage group
d2ea020556 is described below
commit d2ea020556cd51b76f6978557f4d124cdd5fa40b
Author: Jinrui.Zhang <xi...@gmail.com>
AuthorDate: Tue May 3 17:39:09 2022 +0800
fix the scenario that there is no data in corresponding storage group
---
.../org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java | 4 ++++
.../main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java | 8 +++++++-
.../org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java | 2 +-
3 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java b/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java
index bc5b1c8994..b62b0d1193 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/common/schematree/SchemaTree.java
@@ -248,4 +248,8 @@ public class SchemaTree {
SchemaNode getRoot() {
return root;
}
+
+ public boolean isEmpty() {
+ return root.getChildren() == null || root.getChildren().size() == 0;
+ }
}
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
index 8c0972f90e..26a90af04b 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/analyze/Analyzer.java
@@ -29,6 +29,7 @@ import org.apache.iotdb.db.exception.sql.StatementAnalyzeException;
import org.apache.iotdb.db.metadata.path.PartialPath;
import org.apache.iotdb.db.mpp.common.MPPQueryContext;
import org.apache.iotdb.db.mpp.common.filter.QueryFilter;
+import org.apache.iotdb.db.mpp.common.header.DatasetHeader;
import org.apache.iotdb.db.mpp.common.header.HeaderConstant;
import org.apache.iotdb.db.mpp.common.schematree.PathPatternTree;
import org.apache.iotdb.db.mpp.common.schematree.SchemaTree;
@@ -117,7 +118,12 @@ public class Analyzer {
// request schema fetch API
SchemaTree schemaTree = schemaFetcher.fetchSchema(patternTree);
-
+ // (xingtanzjr) If there is no leaf node in the schema tree, the query should be completed
+ // immediately
+ if (schemaTree.isEmpty()) {
+ analysis.setRespDatasetHeader(new DatasetHeader(new ArrayList<>(), false));
+ return analysis;
+ }
// bind metadata, remove wildcards, and apply SLIMIT & SOFFSET
TypeProvider typeProvider = new TypeProvider();
rewrittenStatement =
diff --git a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
index 8b77c4ef1f..dce5dccc71 100644
--- a/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
+++ b/server/src/main/java/org/apache/iotdb/db/mpp/plan/execution/QueryExecution.java
@@ -255,7 +255,7 @@ public class QueryExecution implements IQueryExecution {
/** @return true if there is more tsblocks, otherwise false */
@Override
public boolean hasNextResult() {
- return !resultHandle.isFinished();
+ return resultHandle != null && !resultHandle.isFinished();
}
/** return the result column count without the time column */