You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support custom window frame with AVG aggregate function #4845
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I would like DataFusion to support using the avg aggregate function in a window with custom frame.
Here is a working example using sum:
❯ selectsum(column1) OVER(ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) from (values (1.0), (2.0), (3.0)) as sq;
+-----------------+
| SUM(sq.column1) |
+-----------------+
| 1 |
| 3 |
| 5 |
+-----------------+
But it does not work for avg:
❯ selectavg(column1) OVER(ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) from (values (1.0), (2.0), (3.0)) as sq;
ArrowError(ExternalError(ArrowError(ExternalError(NotImplemented("Retractable Accumulator hasn't been implemented for Avg { name: \"AVG(sq.column1)\", expr: Column { name: \"column1\", index: 0 }, data_type: Float64 } yet")))))
Describe the solution you'd like
I would like avg to support use in windows with custom frames.
Additional context
Looking at the implementation briefly, I think AvgAccumulator needs an implementation of retract_batch, similar to this implementation for SumAccumulator:
Activity