This is an automated email from the ASF dual-hosted git repository.
yiguolei 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 aab8dad191 [fix](sort) fix bug of sort (#17151)
aab8dad191 is described below
commit aab8dad1911abee041327092f5ab2a0bde9142ec
Author: TengJianPing <[email protected]>
AuthorDate: Mon Feb 27 10:55:12 2023 +0800
[fix](sort) fix bug of sort (#17151)
The logic of topn and full sort is wrong when there are both offsets and
limits, the offset is not considered when doing the max heap optimization,
which will lead to wrong result.
---
be/src/vec/common/sort/sorter.cpp | 2 +-
be/src/vec/common/sort/topn_sorter.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/common/sort/sorter.cpp
b/be/src/vec/common/sort/sorter.cpp
index aaf91d4428..424e8f08c9 100644
--- a/be/src/vec/common/sort/sorter.cpp
+++ b/be/src/vec/common/sort/sorter.cpp
@@ -338,7 +338,7 @@ Status FullSorter::_do_sort() {
// to order the block in _block_priority_queue.
// if one block totally greater the heap top of _block_priority_queue
// we can throw the block data directly.
- if (_state->num_rows() < _limit) {
+ if (_state->num_rows() < _offset + _limit) {
_state->add_sorted_block(desc_block);
// if it's spilled, sorted_block is not added into sorted block
vector,
// so it's should not be added to _block_priority_queue, since
diff --git a/be/src/vec/common/sort/topn_sorter.cpp
b/be/src/vec/common/sort/topn_sorter.cpp
index 7e6427706f..ec242c3ac2 100644
--- a/be/src/vec/common/sort/topn_sorter.cpp
+++ b/be/src/vec/common/sort/topn_sorter.cpp
@@ -52,7 +52,7 @@ Status TopNSorter::_do_sort(Block* block) {
// to order the block in _block_priority_queue.
// if one block totally greater the heap top of _block_priority_queue
// we can throw the block data directly.
- if (_state->num_rows() < _limit) {
+ if (_state->num_rows() < _offset + _limit) {
_state->add_sorted_block(sorted_block);
// if it's spilled, sorted_block is not added into sorted block
vector,
// so it's should not be added to _block_priority_queue, since
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]