Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/AggregateFunctions/IAggregateFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,9 @@ class IAggregateFunctionHelper : public IAggregateFunction
auto offset_it = column_sparse.getIterator(row_begin);

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

void mergeBatch(
Expand Down
10 changes: 10 additions & 0 deletions tests/queries/0_stateless/03657_gby_overflow_any_sparse.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
14 changes: 14 additions & 0 deletions tests/queries/0_stateless/03657_gby_overflow_any_sparse.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
DROP TABLE IF EXISTS 03657_gby_overflow;

CREATE TABLE 03657_gby_overflow(key UInt64, val UInt16) ENGINE = MergeTree ORDER BY tuple()
AS SELECT number, 0 from numbers(100000);

SELECT key, any(val) FROM 03657_gby_overflow GROUP BY key ORDER BY key LIMIT 10
SETTINGS group_by_overflow_mode = 'any',
max_rows_to_group_by = 100,
max_threads = 1,
max_block_size = 100,
group_by_two_level_threshold = 1000000000,
group_by_two_level_threshold_bytes = 1000000000;

DROP TABLE 03657_gby_overflow;