v.20.4New Feature

Add arrayReduceInRanges function for aggregating array elements in ranges

Add function arrayReduceInRanges which aggregates array elements in given ranges. #9598 (hcz)
arrayReduceInRanges is a new ClickHouse function that aggregates elements of an array within specified ranges.

Why it matters

This function allows users to efficiently perform aggregation operations on segments of array data defined by given ranges, enabling more flexible and targeted analysis of array elements without manually slicing the arrays beforehand.

How to use it

Use the arrayReduceInRanges function by passing the aggregate function to apply and the array along with the ranges as arguments. For example:

SELECT arrayReduceInRanges('sum', array_column, ranges_column) FROM table

This will apply the sum aggregation to elements of array_column segmented by ranges_column.