ARRAY_UNION function - Amazon Redshift

Amazon Redshift will no longer support the creation of new Python UDFs starting Patch 198. Existing Python UDFs will continue to function until June 30, 2026. For more information, see the blog post .

ARRAY_UNION function

Combines two arrays and returns a single array containing all unique values, removing any duplicates. The function is NULL-safe, meaning it treats NULLs are treated as known objects. The order of elements in the result is not guaranteed.

Syntax

ARRAY_UNION( array1, array2 )

Arguments

array1

A SUPER expression that specifies the first array.

array2

A SUPER expression that specifies the second array.

Return type

The ARRAY_UNION function returns a SUPER type.

Example

The following examples show the ARRAY_UNION function.

SELECT ARRAY_UNION(ARRAY('a','b','b'), ARRAY('b','c','c')); array_union --------------- ["a","b","c"] (1 row)

The order of elements is not guaranteed:

SELECT ARRAY_UNION(ARRAY('b','a','b'), ARRAY(NULL,'b',NULL)); array_union ---------------- ["b","a",null] (1 row)

See also