Class AggregateFunction

java.lang.Object
dev.frostlake.functions.BuiltInFunction
dev.frostlake.functions.AggregateFunction
Direct Known Subclasses:
AnyValue, ApproxCountDistinct, ApproxPercentile, ApproxPercentileAccumulate, ApproxPercentileCombine, ApproxTopK, ApproxTopKAccumulate, ApproxTopKCombine, ArrayAgg, ArrayUnionAgg, ArrayUniqueAgg, Avg, BitAndAgg, BitOrAgg, BitXorAgg, BooleanAggregate, Corr, Count, CountIf, CovarPop, CovarSamp, HashAgg, Kurtosis, ListAgg, Max, MaxBy, Median, Min, MinBy, Mode, ObjectAgg, PercentileCont, PercentileDisc, RegrAvgx, RegrAvgy, RegrCount, RegrIntercept, RegrR2, RegrSlope, RegrSxx, RegrSxy, RegrSyy, Skew, StdDev, StdDevPop, StdDevSamp, Sum, Variance, VarPop, VarSamp, VectorAvg, VectorMax, VectorMin, VectorSum

public abstract class AggregateFunction extends BuiltInFunction
Base class for aggregate functions (SUM, COUNT, LISTAGG, …). An aggregate is a BuiltInFunction whose per-group state lives in an AggregateFunction.Accumulator: the executor creates one accumulator per group, folds every input value into it, and reads the group's result from it at the end. BuiltInFunction.evaluate(java.util.List<java.lang.Object>) is therefore not the aggregation path, and implementations typically return null from it.
  • Constructor Details

    • AggregateFunction

      protected AggregateFunction(String name, DataType returnType)
      Names the aggregate and fixes its declared result type.
      Parameters:
      name - the SQL name the aggregate is registered under
      returnType - the declared type of the aggregate's result
  • Method Details

    • createAccumulator

      public abstract AggregateFunction.Accumulator createAccumulator()
      Creates the fresh, empty per-group state for one evaluation of this aggregate; the executor makes one per group (or per window partition) and never shares them.
      Returns:
      a new accumulator starting from this aggregate's empty-group state