Class VectorAggregateAccumulator

java.lang.Object
dev.frostlake.functions.aggregate.VectorAggregateAccumulator
All Implemented Interfaces:
AggregateFunction.Accumulator

public class VectorAggregateAccumulator extends Object implements AggregateFunction.Accumulator
The element-wise vector aggregates' accumulator, shared by VectorSum, VectorAvg, VectorMin and VectorMax.

Live-verified over the deliberately CROSSING rows [1,9,3], [4,5,-6] and [7,2,0] — where a row-wise winner would give a different answer than an element-wise one: VECTOR_MIN is [1.0,2.0,-6.0] and VECTOR_MAX is [7.0,9.0,3.0], so each DIMENSION is reduced independently. VECTOR_SUM is [12.0,16.0,-3.0] and VECTOR_AVG [4.0,5.3333335,-1.0] — the float64 mean 16/3 narrowed to a float32 element.

NULL rows are SKIPPED and do not count towards the average (VECTOR_AVG over [1,2,3], [4,5,6] and a NULL row is [2.5,3.5,4.5], i.e. divided by 2), and a group with no non-NULL row is SQL NULL rather than a zero vector.

The result's element type follows the INPUT for SUM / MIN / MAX (VECTOR_SUM over a VECTOR(INT,3) column is [5,14,-3], SYSTEM$TYPEOF VECTOR(INT, 3)) and is always FLOAT for AVG (VECTOR_AVG over the same column is [2.5,7.0,-1.5], VECTOR(FLOAT, 3)).