REDUCE
Description
Reduces an array to an accumulated value by applying a LAMBDA to each value and returning the value in the accumulator.
This function is useful for aggregations and final calculations, such as finding a total or maximum value from an array.
Syntax
REDUCE(
initial_value
, array
, lambda
) - initial_value: Sets the starting value for the accumulator.
- array: The array to be reduced.
- lambda: The LAMBDA that defines the operation to reduce the array. There are three parameters:
- accumulator: The value returned as the final result.
- value: The current value from the array.
- body: The calculation applied to each element in the array.