Class ListAgg


public class ListAgg extends AggregateFunction
LISTAGG(<expr> [, <delimiter>]) — concatenate values into a single string. The optional delimiter defaults to the empty string (Snowflake semantics) and, when present, is applied by the executor via ListAggAccumulator.setDelimiter(java.lang.String).
  • Constructor Details

    • ListAgg

      public ListAgg()
  • Method Details

    • 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
    • semiStructuredRejection

      public SemiStructuredRejection semiStructuredRejection(int position)
      LISTAGG joins its input as text, so neither position takes a semi-structured value. Live LISTAGG(o) is "Invalid argument types for function 'LISTAGG': (OBJECT)", LISTAGG(a) names ARRAY, LISTAGG(s, o) names the DELIMITER position, and the DISTINCT and WITHIN GROUP (ORDER BY …) forms reject identically — while LISTAGG(v) over a VARIANT is accepted even when the VARIANT holds an object.

      Declared here rather than by extending TextArgumentFunction only because an aggregate already extends AggregateFunction; the rule is the same one.

      Overrides:
      semiStructuredRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the refusal this position gives a semi-structured value, or NONE when undeclared
    • binaryRejection

      public SemiStructuredRejection binaryRejection(int position)
      A BINARY value or delimiter is refused with the argument-type list, both declared widths spelled (live-verified).
      Overrides:
      binaryRejection in class BuiltInFunction
      Parameters:
      position - the zero-based argument position being asked about
      Returns:
      the refusal this position gives a BINARY value; by default none