Interface AggregateFunction


public interface AggregateFunction
One aggregate a library supplies: its form plus the Accumulator that reduces a group.

Unlike ScalarFunction this is not sealed — an aggregate has one way of receiving its input, a row at a time, so there is nothing for the engine to dispatch over.

  • Method Details

    • signature

      AggregateSignature signature()
      The form of this aggregate — name, parameters, arity, return type, NULL handling.
      Returns:
      the signature; never null
    • accumulator

      Accumulator accumulator(FunctionContext context)
      Creates the running state for one group.

      Called once per group, and the returned accumulator is used by one group only, so it may hold whatever mutable state the reduction needs.

      Parameters:
      context - the ambient state this reduction may read
      Returns:
      a fresh accumulator; never null
    • name

      default String name()
      Returns:
      the canonical spelling of this aggregate's name
    • returnTypeFor

      default Type returnTypeFor(List<Type> argumentTypes)
      The result type of a call with these argument types.

      Defaults to the declared return type. Override it for an aggregate whose result follows its input — one that yields a companion column's value has the type of that column, whatever it is.

      Parameters:
      argumentTypes - the argument types at the call site, in order
      Returns:
      the result type of that call
    • pushdown

      default PushdownSpelling pushdown()
      How this aggregate is spelled in a backend that could compute it itself.

      Defaults to PushdownSpelling.NONE, so the engine reduces every group itself. A backend spelling is what lets a grouping be pushed into the source.

      Returns:
      the pushdown spelling; never null