v.21.11New Features
Add exponentialMovingAverage aggregate function as a window function
Add aggregate function exponentialMovingAverage that can be used as window function. This closes #27511. #28914 (alexey-milovidov).Why it matters
This feature addresses the need for efficient calculation of exponentially weighted moving averages within queries, enabling users to perform smoothing and trend analysis directly in ClickHouse without external processing.How to use it
Use theexponentialMovingAverage function as a window function in SQL queries by specifying it in the SELECT clause with the OVER clause. For example:SELECT
timestamp,
value,
exponentialMovingAverage(value) OVER (ORDER BY timestamp ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS ema
FROM tableThis computes the exponential moving average of
value ordered by timestamp.