Thanks for this good example Merlin ! I didn't know you could use variable inside custom aggregates, and this allow to solve the problem!
In my own problem I couldn't use aggregates because _as it output at most one row, it would have mean a lots of useless computation (as in this example I guess, (please correct me if it's not the case) : we do N computations of aggregate , each "using" at most N rows) _I couldn't cheat with arrays because of cost of serialization/deserialization I'll keep in mind this custom aggregate use and try to learn more about it. Cheers, Rémi-C