Combine Two Arrays Without Duplicates | ARRAY_UNION

Syntax

ARRAY_UNION( [...values] )

Parameters

values
Any number of ARRAY values for which the union will be computed.

Return Value

An ARRAY containing all the unique items in all of the VALUES.

Description

Combine any number of ARRAYS while removing duplicates. Equality of ARRAY and MAP values are performed structurally as is done with the EQUAL operation.

Examples

ARRAY_UNION([1, 2, 3]) # returns [1, 2, 3]
ARRAY_UNION() # returns []
ARRAY_UNION([1, 2, 3], [2, 3, 4]) # returns [1, 2, 3, 4]
ARRAY_UNION([[1, 2], [3, 4]], [[1, 2], [4, 5]]) # returns [[1, 2], [3, 4], [4, 5]]
ARRAY_UNION([1, 2], [2, 3], [1, 4], [4, 5], [7]) # returns [1, 2, 3, 4, 5, 7]