v.19.11New Feature

Aggregate Functions Grouparraymovingsum(win_size)(x) and Grouparraymovingavg(win_size)(x), Which Calculate Moving Sum/avg with or Without Window-size Limitation

Aggregate functions groupArrayMovingSum(win_size)(x) and groupArrayMovingAvg(win_size)(x), which calculate moving sum/avg with or without window-size limitation. #5595 (inv2004)
Introduced aggregate functions groupArrayMovingSum(win_size)(x) and groupArrayMovingAvg(win_size)(x) to compute moving sum and moving average over arrays with an optional window size limitation.

Why it matters

These functions address the need to efficiently calculate moving sums and averages on grouped array data within ClickHouse, supporting time-series analysis and other scenarios where sliding window computations over grouped data arrays are required.

How to use it

Use the functions within your SQL queries by specifying the window size and the target array column, for example:

SELECT groupArrayMovingSum(3)(x), groupArrayMovingAvg(5)(x) FROM table GROUP BY key

where win_size determines the size of the moving window.