Class ArrayAgg


public class ArrayAgg extends AggregateFunction
  • Constructor Details

    • ArrayAgg

      public ArrayAgg()
  • Method Details

    • structuredRejection

      public SemiStructuredRejection structuredRejection(int position)
      A plain OBJECT or ARRAY collects perfectly well, a STRUCTURED one does not. Live over one table carrying both, ARRAY_AGG(o) returns [{"k":"v1"},{"k":"v2"}] while ARRAY_AGG(so) is "Invalid argument types for function 'ARRAY_AGG': (OBJECT(x VARCHAR(16777216)))" — and the same for ARRAY_AGG(sa) / ARRAY_AGG(sm), for DISTINCT, for WITHIN GROUP (ORDER BY …), for the windowed OVER () form, under GROUP BY and on an EMPTY input. Only the aggregated VALUE is constrained: ARRAY_AGG(n) WITHIN GROUP (ORDER BY so) sorts by a structured key quite happily.
      Overrides:
      structuredRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the extra refusal this position gives a structured value, or NONE when undeclared
    • createAccumulator

      public AggregateFunction.Accumulator createAccumulator()
      Description copied from class: AggregateFunction
      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.
      Specified by:
      createAccumulator in class AggregateFunction
      Returns:
      a new accumulator starting from this aggregate's empty-group state
    • evaluate

      public Object evaluate(List<Object> args)
      Description copied from class: BuiltInFunction
      Computes the function's result over its already-evaluated argument values. A SQL NULL argument arrives as Java null, and returning null makes the SQL result NULL.
      Specified by:
      evaluate in class BuiltInFunction
      Parameters:
      args - the argument values, in call order
      Returns:
      the function's value for these arguments, or null for SQL NULL
    • getMinArgCount

      public int getMinArgCount()
      Description copied from class: BuiltInFunction
      The fewest arguments a call to this function may pass; fewer is an argument-count error.
      Specified by:
      getMinArgCount in class BuiltInFunction
      Returns:
      the minimum accepted argument count
    • getMaxArgCount

      public int getMaxArgCount()
      Description copied from class: BuiltInFunction
      The most arguments a call to this function may pass; Integer.MAX_VALUE marks a variadic function (see BuiltInFunction.isVariadic()).
      Specified by:
      getMaxArgCount in class BuiltInFunction
      Returns:
      the maximum accepted argument count