Skip to content

Commit 1072419

Browse files
nextdreambluepull[bot]
authored andcommitted
[fix](aggregate) agg table and unique table get different result when… (#14822)
Signed-off-by: nextdreamblue <[email protected]>
1 parent de1fd22 commit 1072419

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

‎be/src/olap/generic_iterators.cpp‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -263,15 +263,18 @@ class MergeIterator : public RowwiseIterator {
263263
}
264264

265265
// if row cursors equal, compare segment id.
266-
// here we sort segment id in reverse order, because of the row order in AGG_KEYS
267-
// dose no matter, but in UNIQUE_KEYS table we only read the latest is one, so we
268-
// return the row in reverse order of segment id
269-
bool result = res == 0 ? lhs->data_id() < rhs->data_id() : res < 0;
266+
// when in UNIQUE_KEYS table, we need only read the latest one, so we
267+
// return the row in reverse order of segment id.
268+
// when in AGG_KEYS table, we return the row in order of segment id, because
269+
// we need replace the value with lower segment id by the one with higher segment id when
270+
// non-vectorized.
270271
if (_is_unique) {
272+
bool result = res == 0 ? lhs->data_id() < rhs->data_id() : res < 0;
271273
result ? lhs->set_skip(true) : rhs->set_skip(true);
274+
return result;
272275
}
273276

274-
return result;
277+
return lhs->data_id() > rhs->data_id();
275278
}
276279

277280
int _sequence_id_idx;

0 commit comments

Comments
 (0)