> ## Documentation Index
> Fetch the complete documentation index at: https://docs.e6data.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ARRAY_DISTINCT

> Removes duplicate elements, keeping their first occurrence.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

Returns NULL for a NULL array. At most one NULL element remains.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
array_distinct(array)
```

## Arguments

Type notation used below:

* T is the array element type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY or STRUCT.

| Name | Type | Required | Description |
| - | - | - | - |
| array | ARRAY\<T> | Yes | The array from which to remove duplicate values. Nested elements/fields must satisfy the same element-type restrictions. |

## Returns

* Type: ARRAY\<T>
* Possible values: The distinct input values.
* NULL behavior: Returns NULL for a NULL array. At most one NULL element remains.
* Shape: Zero through the original number of elements.
* Ordering: First-occurrence encounter order.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* When removing duplicates, all NaN values are treated as equal, as are positive and negative zero.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT array_distinct(ARRAY[1, 2, 1, NULL, NULL]) AS "value";
```

| value |
| - |
| \[1,2,null] |

### Remove repeated strings

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT array_distinct(ARRAY('red', 'blue', 'red')) AS colors;
```

| colors |
| - |
| \["red","blue"] |

## Limitations

* Elements must be comparable. MAP elements are not supported, including maps nested inside other elements.
* MAP elements, including MAP values nested inside compared elements, are outside the supported element types.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.