list_distinct()

Removes all duplicates and NULL values from a list. Does not preserve the original order.

Arguments & returns

list_distinct(list)

Scalar
Overload link list Returns
#01 T[] T[]

Example

list_distinct example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

In other engines

Used in larger rewrites 1

These examples use list_distinct as one part of a larger SQL translation.

Snowflakearray_distinct()

SELECT ARRAY_DISTINCT(col)
In Haybarn
SELECT CASE WHEN ARRAY_LENGTH(col) <> LIST_COUNT(col) THEN LIST_APPEND(LIST_DISTINCT(LIST_FILTER(col, _u -> NOT _u IS NULL)), NULL) ELSE LIST_DISTINCT(col) END

SQLGlot example ↗