Skip to content

Commit

Permalink
[bug](distinct-agg) fix limit value not effective in some case
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangstar333 committed Aug 2, 2023
1 parent a4ef340 commit 093f2f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ 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 need_cut_rows = (_output_block->rows() + _output_distinct_rows) - _node->limit();
auto limit_rows = _output_block->rows() - need_cut_rows;
_output_block->set_num_rows(limit_rows);
_output_distinct_rows += limit_rows;
_data_queue->push_block(std::move(_output_block));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DistinctStreamingAggSinkOperator final
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:
Expand Down

0 comments on commit 093f2f2

Please sign in to comment.