From 8a759d023e805d089133cf42f5fc3c9ba417fa0a Mon Sep 17 00:00:00 2001 From: daidai Date: Mon, 21 Jul 2025 17:21:23 +0800 Subject: [PATCH] [fix](result-sink)Fix the correctness of the results when multiple be and dry_run_query=true. --- .../src/main/java/org/apache/doris/qe/Coordinator.java | 8 +++++--- .../java/org/apache/doris/qe/runtime/QueryProcessor.java | 8 +++++--- 2 files changed, 10 insertions(+), 6 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 87ffa67944029a..571f01759d5780 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 @@ -1190,9 +1190,11 @@ public RowBatch getNext() throws Exception { } if (ConnectContext.get() != null && ConnectContext.get().getSessionVariable().dryRunQuery) { - if (resultBatch.isEos()) { - numReceivedRows += resultBatch.getQueryStatistics().getReturnedRows(); - } + // In BE: vmysql_result_writer.cpp:GetResultBatchCtx::on_close() + // statistics->set_returned_rows(returned_rows); + // In a multi-mysql_result_writer scenario, since each mysql_result_writer will set this rows, in order + // to avoid missing rows when dry_run_query = true, they should all be added up. + numReceivedRows += resultBatch.getQueryStatistics().getReturnedRows(); } else if (resultBatch.getBatch() != null) { numReceivedRows += resultBatch.getBatch().getRowsSize(); } diff --git a/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/QueryProcessor.java b/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/QueryProcessor.java index f2ad708a39425a..92cebc8ba7479c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/QueryProcessor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/qe/runtime/QueryProcessor.java @@ -142,9 +142,11 @@ public RowBatch getNext() throws UserException, InterruptedException, TException ConnectContext connectContext = coordinatorContext.connectContext; if (connectContext != null && connectContext.getSessionVariable().dryRunQuery) { - if (resultBatch.isEos()) { - numReceivedRows += resultBatch.getQueryStatistics().getReturnedRows(); - } + // In BE: vmysql_result_writer.cpp:GetResultBatchCtx::on_close() + // statistics->set_returned_rows(returned_rows); + // In a multi-mysql_result_writer scenario, since each mysql_result_writer will set this rows, in order + // to avoid missing rows when dry_run_query = true, they should all be added up. + numReceivedRows += resultBatch.getQueryStatistics().getReturnedRows(); } else if (resultBatch.getBatch() != null) { numReceivedRows += resultBatch.getBatch().getRowsSize(); }