sumarray()

Returns the sum of all elements in a given array. sumarray() function will always exclude the null and non-numeric value.

Syntax

subarray(ARRAY_EXPR)
ARRAY_EXPR
Expression that returns an array

Usage

json "{}"
| eval sum=sumarray(array(1, 2, 3, 4, 5))
| # Return value: 15
json "{}"
| eval arr=sumarray(array(1, 2, 3, null, "a", 4, 5))
| # Retrun value: 15
json "{}"
| eval arr=sumarray(array(null, null, null, "a", "b"))
| # Return value: 0