Skip to content

Commit 3b86faf

Browse files
antaljanosbenjaminmkmkme
authored andcommitted
Merge pull request ClickHouse#88440 from korowa/fix-gby-overflow-sparse
Fix sparse columns aggregation for any overflow mode
1 parent 6d9bede commit 3b86faf

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/AggregateFunctions/IAggregateFunction.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,9 @@ class IAggregateFunctionHelper : public IAggregateFunction
482482
auto offset_it = column_sparse.getIterator(row_begin);
483483

484484
for (size_t i = row_begin; i < row_end; ++i, ++offset_it)
485-
static_cast<const Derived *>(this)->add(places[offset_it.getCurrentRow()] + place_offset,
486-
&values, offset_it.getValueIndex(), arena);
485+
if (places[offset_it.getCurrentRow()])
486+
static_cast<const Derived *>(this)->add(places[offset_it.getCurrentRow()] + place_offset,
487+
&values, offset_it.getValueIndex(), arena);
487488
}
488489

489490
void mergeBatch(
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
0 0
2+
1 0
3+
2 0
4+
3 0
5+
4 0
6+
5 0
7+
6 0
8+
7 0
9+
8 0
10+
9 0
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
DROP TABLE IF EXISTS 03657_gby_overflow;
2+
3+
CREATE TABLE 03657_gby_overflow(key UInt64, val UInt16) ENGINE = MergeTree ORDER BY tuple()
4+
AS SELECT number, 0 from numbers(100000);
5+
6+
SELECT key, any(val) FROM 03657_gby_overflow GROUP BY key ORDER BY key LIMIT 10
7+
SETTINGS group_by_overflow_mode = 'any',
8+
max_rows_to_group_by = 100,
9+
max_threads = 1,
10+
max_block_size = 100,
11+
group_by_two_level_threshold = 1000000000,
12+
group_by_two_level_threshold_bytes = 1000000000;
13+
14+
DROP TABLE 03657_gby_overflow;

0 commit comments

Comments
 (0)