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
3 changes: 2 additions & 1 deletion src/AggregateFunctions/AggregateFunctionSum.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,8 @@ class AggregateFunctionSum final : public IAggregateFunctionDataHelper<Data, Agg
size_t to = std::lower_bound(offsets.begin(), offsets.end(), row_end) - offsets.begin();

for (size_t i = from; i < to; ++i)
add(places[offsets[i]] + place_offset, &values, i + 1, arena);
if (places[offsets[i]])
add(places[offsets[i]] + place_offset, &values, i + 1, arena);
}

void merge(AggregateDataPtr __restrict place, ConstAggregateDataPtr rhs, Arena *) const override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
CREATE TABLE 03811_sparse_column_aggregation_with_sum(key UInt128, val UInt16) ENGINE = MergeTree ORDER BY tuple();

INSERT INTO 03811_sparse_column_aggregation_with_sum
SELECT number, number % 10000 = 0 FROM numbers(100000)
SETTINGS min_insert_block_size_rows = 1000,
max_block_size =1000,
max_threads = 2;

SELECT key, sum(val) AS c
FROM 03811_sparse_column_aggregation_with_sum
GROUP BY key
ORDER BY c DESC
LIMIT 100
FORMAT Null
SETTINGS group_by_overflow_mode = 'any',
max_rows_to_group_by = 100,
group_by_two_level_threshold_bytes = 1,
group_by_two_level_threshold = 1,
max_threads = 2;

DROP TABLE 03811_sparse_column_aggregation_with_sum;