Array Reduce Functions
AMPS includes a set of functions designed to operate over an array element in a message and produce a value. These functions take an array within a single message as input, and reduce that array to a single value as output.
ARRAY_COUNT
ARRAY_COUNT
ARRAY_COUNT(array)
Returns the number of elements in the array.
Parameters
array
: The array to count the elements of.
Returns
The number of elements in the array.
ARRAY_MAX
ARRAY_MAX
ARRAY_MAX(array)
Returns the largest value in the array.
Parameters
array
: The array to find the maximum value of.
Returns
The largest value in the array, using the standard AMPS >
comparison.
ARRAY_MIN
ARRAY_MIN
ARRAY_MIN(array)
Returns the minimum value in the array.
Parameters
array
: The array to find the minimum value of.
Returns
The minimum value in the array, using the standard AMPS <
comparison.
ARRAY_SUM
ARRAY_SUM
ARRAY_SUM(array)
Returns a number produced by adding all of the elements in the array. NULL
values in the array are ignored.
Parameters
array
: The array to sum.
Returns
The sum of all elements in the array.
ARRAY_TO_STRING
ARRAY_TO_STRING
ARRAY_TO_STRING(array, delimiter, null_replacement)
Returns a string comprised of the elements of the array, separated by the provided delimiter. NULL
values in the array are replaced with the provided null_replacement
value.
Parameters
array
: The array to convert to a string.delimiter
: The delimiter to use between array elements.null_replacement
: The value to use forNULL
elements in the array.
Returns
A string representation of the array.