Skip to main content
Sums all the elements in an array. From StarRocks 2.5, array_sum() can take a lambda expression as an argument. However, it cannot work directly with the Lambda expression. It must work on the result converted from array_map().

Syntax

Parameters

  • array(type): the array you want to calculate the sum. Array elements support the following data types: BOOLEAN, TINYINT, SMALLINT, INT, BIGINT, LARGEINT, FLOAT, DOUBLE, and DECIMALV2.
  • lambda_function: the lambda expression used to calculate the target array for array_sum().

Return value

Returns a numeric value.

Examples

Use array_sum without lambda function

text

Use array_sum with lambda function

text

keyword

ARRAY_SUM,ARRAY