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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit 30dadb73fedeb6e70a1740f2f27c8b214331a949
Author: zhangstar333 <87313068+zhangstar...@users.noreply.github.com>
AuthorDate: Thu Aug 3 10:35:36 2023 +0800

    [bug](distinct-agg) fix limit value not effective in some case (#22517)
    
    fix limit value not effective in some case
---
 be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.cpp | 2 +-
 be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.h   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.cpp 
b/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.cpp
index 48695ed56f..635817973c 100644
--- a/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.cpp
+++ b/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.cpp
@@ -55,7 +55,7 @@ Status DistinctStreamingAggSinkOperator::sink(RuntimeState* 
state, vectorized::B
         // get enough data or reached limit rows, need push block to queue
         if (_node->limit() != -1 &&
             (_output_block->rows() + _output_distinct_rows) >= _node->limit()) 
{
-            auto limit_rows = _node->limit() - _output_block->rows();
+            auto limit_rows = _node->limit() - _output_distinct_rows;
             _output_block->set_num_rows(limit_rows);
             _output_distinct_rows += limit_rows;
             _data_queue->push_block(std::move(_output_block));
diff --git 
a/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.h 
b/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.h
index ae7106178e..46b1dda008 100644
--- a/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.h
+++ b/be/src/pipeline/exec/distinct_streaming_aggregation_sink_operator.h
@@ -63,7 +63,7 @@ public:
     Status close(RuntimeState* state) override;
 
     bool reached_limited_rows() {
-        return _node->limit() != -1 && _output_distinct_rows > _node->limit();
+        return _node->limit() != -1 && _output_distinct_rows >= _node->limit();
     }
 
 private:


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

Reply via email to