Skip to main content

ARRAY_PRODUCT

Description

Calculates the product of all elements in an array

Syntax

ARRAY_PRODUCT(<arr>)

Parameters

ParameterDescription
<arr>Corresponding array

Return Value

Returns the product of all elements in the array. NULL values in the array will be skipped. For an empty array or an array with all NULL values, the result returns a NULL value.

Example

SELECT ARRAY_PRODUCT([1, 2, 3]),ARRAY_PRODUCT([1, NULL, 3]),ARRAY_PRODUCT([NULL]);
+--------------------------+-----------------------------+----------------------------------------------+
| array_product([1, 2, 3]) | array_product([1, NULL, 3]) | array_product(cast([NULL] as ARRAY<DOUBLE>)) |
+--------------------------+-----------------------------+----------------------------------------------+
| 6 | 3 | NULL |
+--------------------------+-----------------------------+----------------------------------------------+