View a markdown version of this page

ARRAY_DISTINCT function - Amazon Redshift

Amazon Redshift will no longer support the use of Python UDFs after June 30, 2026. We will start enforcing it in phases. For more information on the details of Python end of life and migration options, see the blog post that was published on June 30, 2025.

ARRAY_DISTINCT function

Creates a new array containing only unique elements from the input array, removing all duplicates. The order of elements in the output array is not guaranteed to match the input order. NULL values are treated as valid elements; if multiple NULLs exist in the input array, only one NULL appears in the output.

Syntax

ARRAY_DISTINCT( array )

Arguments

array

A SUPER expression that specifies the array.

Return type

The ARRAY_DISTINCT function returns a SUPER type.

Example

The following examples show the ARRAY_DISTINCT function.

SELECT ARRAY_DISTINCT(ARRAY(1, 1, 'a', 'a', NULL, NULL)); array_distinct ---------------- [1,"a",null] (1 row) SELECT ARRAY_DISTINCT(ARRAY_CONCAT(ARRAY(1,2,3,3),ARRAY(2,3,4,4))); array_distinct ---------------- [1,2,3,4] (1 row)

See also