HappenLee opened a new pull request, #63499:
URL: https://github.com/apache/doris/pull/63499
### What problem does this PR solve?
Issue Number: N/A
Problem Summary:
Doris lacked an exponential moving average aggregate function. This
implements `exponential_moving_average(half_decay, value, time)` ported
from ClickHouse's ExponentialMovingAverage aggregate.
Algorithm:
- State stores (value, time, half_decay) as doubles.
- On add(): scale existing value to the new timestamp via
`2^(-dt/half_decay)`, then accumulate. Store half_decay in state so
it is available during merge().
- On merge(): advance both states to the later timestamp, then sum.
This is commutative and associative, so row order doesn't matter.
- Result: `value * (1 - 2^(-1/half_decay))` (normalised by sum of
weights).
Changes:
- BE: `aggregate_function_ema.h/cpp` — state struct + function class,
registered in `aggregate_function_simple_factory.cpp`.
- FE: `ExponentialMovingAverage.java` — 3-arg DOUBLE signature, visitor
method added to `AggregateFunctionVisitor`, registered in
`BuiltinAggregateFunctions`.
- Regression test: `query_p0/aggregate/exponential_moving_average/`.
### Release note
New aggregate function `exponential_moving_average(half_decay, value,
time)`
computes the exponential moving average over a stream of (value, time)
pairs with the given half-decay parameter.
### Check List (For Author)
- Test: Regression test added
(query_p0/aggregate/exponential_moving_average)
- Behavior changed: No (new function)
- Does this need documentation:
[docs](https://github.com/apache/doris-website/pull/3726)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]