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

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


The following commit(s) were added to refs/heads/master by this push:
     new ff36e08fcb8 [Bug](dry-run) make dryrun result set collect multi 
batch's QueryStatistics (#38303)
ff36e08fcb8 is described below

commit ff36e08fcb8475fdecd73ff8d1954a837d5d5612
Author: Pxl <pxl...@qq.com>
AuthorDate: Thu Jul 25 20:07:06 2024 +0800

    [Bug](dry-run) make dryrun result set collect multi batch's QueryStatistics 
(#38303)
    
    ## Proposed changes
     make dryrun result set collect multi batch's QueryStatistics
---
 .../src/main/java/org/apache/doris/qe/Coordinator.java | 18 ++++++++++++------
 .../main/java/org/apache/doris/qe/StmtExecutor.java    |  9 +++++++--
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
index fdfa468538d..70857c9be5b 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/Coordinator.java
@@ -303,6 +303,10 @@ public class Coordinator implements CoordInterface {
         this.tWorkloadGroups = tWorkloadGroups;
     }
 
+    public long getNumReceivedRows() {
+        return numReceivedRows;
+    }
+
     public List<TPipelineWorkloadGroup> gettWorkloadGroups() {
         return tWorkloadGroups;
     }
@@ -1187,6 +1191,14 @@ public class Coordinator implements CoordInterface {
             }
         }
 
+        if (ConnectContext.get() != null && 
ConnectContext.get().getSessionVariable().dryRunQuery) {
+            if (resultBatch.isEos()) {
+                numReceivedRows += 
resultBatch.getQueryStatistics().getReturnedRows();
+            }
+        } else if (resultBatch.getBatch() != null) {
+            numReceivedRows += resultBatch.getBatch().getRowsSize();
+        }
+
         if (resultBatch.isEos()) {
             receivers.remove(receivers.size() - 1);
             if (receivers.isEmpty()) {
@@ -1204,12 +1216,6 @@ public class Coordinator implements CoordInterface {
                 }
                 cancelInternal(new Status(TStatusCode.LIMIT_REACH, "query 
reach limit"));
             }
-            if (ConnectContext.get() != null && 
ConnectContext.get().getSessionVariable().dryRunQuery) {
-                numReceivedRows = 0;
-                numReceivedRows += 
resultBatch.getQueryStatistics().getReturnedRows();
-            }
-        } else if (resultBatch.getBatch() != null) {
-            numReceivedRows += resultBatch.getBatch().getRowsSize();
         }
 
         return resultBatch;
diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java 
b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
index 825b38cc757..3f5d480a4af 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
@@ -2008,8 +2008,13 @@ public class StmtExecutor {
                 if (!isOutfileQuery) {
                     if (ConnectContext.get() != null && isDryRun) {
                         // Return a one row one column result set, with the 
real result number
-                        List<String> data = 
Lists.newArrayList(batch.getQueryStatistics() == null ? "0"
-                                : batch.getQueryStatistics().getReturnedRows() 
+ "");
+                        long rows = 0;
+                        if (coordBase instanceof Coordinator) {
+                            rows = ((Coordinator) 
coordBase).getNumReceivedRows();
+                        } else if (batch.getQueryStatistics() != null) {
+                            rows = 
batch.getQueryStatistics().getReturnedRows();
+                        }
+                        List<String> data = 
Lists.newArrayList(String.valueOf(rows));
                         ResultSet resultSet = new 
CommonResultSet(DRY_RUN_QUERY_METADATA,
                                 Collections.singletonList(data));
                         sendResultSet(resultSet);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to