Skip to main content

ARRAY_DISTINCT

Introduced or updated: v1.2.762

Removes duplicate elements from a JSON array and returns an array with only distinct elements.

Aliases

  • JSON_ARRAY_DISTINCT

Syntax

ARRAY_DISTINCT(<json_array>)

Return Type

JSON array.

Examples

SELECT ARRAY_DISTINCT('["apple", "banana", "apple", "orange", "banana"]'::VARIANT);

-[ RECORD 1 ]-----------------------------------
array_distinct('["apple", "banana", "apple", "orange", "banana"]'::VARIANT): ["apple","banana","orange"]
Try Databend Cloud for FREE

Multimodal, object-storage-native warehouse for BI, vectors, search, and geo.

Snowflake-compatible SQL with automatic scaling.

Sign up and get $200 in credits.

Try it today