Links

ARRAY_SUM

This function calculates the sum of all non-null elements of the input. If there are no non-null elements, returns 0. The behavior is similar to aggregate function SUM, but operates on an array.

Syntax

ARRAY_SUM(array)

Arguments

Name
Type
Description
Default Value
array
numeric
A numeric array

Returns

the sum of all non-null elements of the input. if there are no non-null elements, returns 0. a primitive value input is considered to be an array with a single element.

Examples

array
Output
array[1, 0.2, 30]
31.2

Transformation job example

SQL

CREATE JOB function_operator_example
ADD_MISSING_COLUMNS = true
AS INSERT INTO default_glue_catalog.upsolver_samples.orders_transformed_data MAP_COLUMNS_BY_NAME
SELECT array[],
ARRAY_SUM(array[]) AS Output
FROM default_glue_catalog.upsolver_samples.orders_raw_data
LET array = array[1, 0.2, 30]
WHERE time_filter()
LIMIT 1;

Query result

array[]
Output
array[1, 0.2, 30]
31.2