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

haonan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new dcadc62f53 [IOTDB-3834] fixed [0.14]grafana-plugin display data error 
(#6683)
dcadc62f53 is described below

commit dcadc62f5384c041fabfabb2a3ecf40621ccddce
Author: CloudWise-Lukemiao 
<[email protected]>
AuthorDate: Fri Jul 15 17:39:33 2022 +0800

    [IOTDB-3834] fixed [0.14]grafana-plugin display data error (#6683)
---
 .../mpprest/handler/QueryDataSetHandler.java       | 37 +++++++++++++++++-----
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git 
a/server/src/main/java/org/apache/iotdb/db/protocol/mpprest/handler/QueryDataSetHandler.java
 
b/server/src/main/java/org/apache/iotdb/db/protocol/mpprest/handler/QueryDataSetHandler.java
index eaa55d1d3f..99f0016e37 100644
--- 
a/server/src/main/java/org/apache/iotdb/db/protocol/mpprest/handler/QueryDataSetHandler.java
+++ 
b/server/src/main/java/org/apache/iotdb/db/protocol/mpprest/handler/QueryDataSetHandler.java
@@ -33,7 +33,6 @@ import 
org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
 
 import javax.ws.rs.core.Response;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
@@ -46,12 +45,12 @@ public class QueryDataSetHandler {
    * @param actualRowSizeLimit max number of rows to return. no limit when 
actualRowSizeLimit <= 0.
    */
   public static Response fillQueryDataSet(
-      IQueryExecution queryExecution, Statement statement, int 
actualRowSizeLimit)
-      throws IOException {
+      IQueryExecution queryExecution, Statement statement, int 
actualRowSizeLimit) {
     if (statement instanceof ShowStatement) {
       return fillShowPlanDataSet(queryExecution, actualRowSizeLimit);
     } else if (statement instanceof QueryStatement) {
-      if (((QueryStatement) statement).isAggregationQuery()) {
+      if (((QueryStatement) statement).isAggregationQuery()
+          && !((QueryStatement) statement).isGroupByTime()) {
         return fillAggregationPlanDataSet(queryExecution, actualRowSizeLimit);
       }
       return fillDataSetWithTimestamps(queryExecution, actualRowSizeLimit, 1);
@@ -97,7 +96,7 @@ public class QueryDataSetHandler {
   }
 
   private static Response fillShowPlanDataSet(
-      IQueryExecution queryExecution, final int actualRowSizeLimit) throws 
IOException {
+      IQueryExecution queryExecution, final int actualRowSizeLimit) {
     org.apache.iotdb.db.protocol.rest.model.QueryDataSet targetDataSet =
         new org.apache.iotdb.db.protocol.rest.model.QueryDataSet();
     initTargetDatasetOrderByOrderWithSourceDataSet(
@@ -138,7 +137,18 @@ public class QueryDataSetHandler {
       final long timePrecision) {
     int fetched = 0;
     int columnNum = queryExecution.getOutputValueColumnCount();
-    while (fetched < actualRowSizeLimit) {
+    while (true) {
+      if (0 < actualRowSizeLimit && actualRowSizeLimit <= fetched) {
+        return Response.ok()
+            .entity(
+                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                    .code(TSStatusCode.QUERY_PROCESS_ERROR.getStatusCode())
+                    .message(
+                        String.format(
+                            "Dataset row size exceeded the given max row size 
(%d)",
+                            actualRowSizeLimit)))
+            .build();
+      }
       Optional<TsBlock> optionalTsBlock = queryExecution.getBatchResult();
       if (!optionalTsBlock.isPresent()) {
         break;
@@ -180,7 +190,18 @@ public class QueryDataSetHandler {
       org.apache.iotdb.db.protocol.rest.model.QueryDataSet targetDataSet) {
     int fetched = 0;
     int columnNum = queryExecution.getOutputValueColumnCount();
-    while (fetched < actualRowSizeLimit) {
+    while (true) {
+      if (0 < actualRowSizeLimit && actualRowSizeLimit <= fetched) {
+        return Response.ok()
+            .entity(
+                new org.apache.iotdb.db.protocol.rest.model.ExecutionStatus()
+                    .code(TSStatusCode.QUERY_PROCESS_ERROR.getStatusCode())
+                    .message(
+                        String.format(
+                            "Dataset row size exceeded the given max row size 
(%d)",
+                            actualRowSizeLimit)))
+            .build();
+      }
       Optional<TsBlock> optionalTsBlock = queryExecution.getBatchResult();
       if (!optionalTsBlock.isPresent()) {
         break;
@@ -232,7 +253,7 @@ public class QueryDataSetHandler {
     return Response.ok().entity(results).build();
   }
 
-  public static Response fillGrafanaNodesResult(IQueryExecution 
queryExecution) throws IOException {
+  public static Response fillGrafanaNodesResult(IQueryExecution 
queryExecution) {
     List<String> nodes = new ArrayList<>();
     Optional<TsBlock> optionalTsBlock = queryExecution.getBatchResult();
     if (!optionalTsBlock.isPresent()) {

Reply via email to