> ## 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_UNIQUE_AGG

> Collects distinct non-NULL values into an array.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Aggregate · Window</span></div>

NULL values are ignored. The array itself is non-NULL.

## Syntax

A window function keeps each input row and adds a result for that row. `PARTITION BY` groups rows with matching values; without it, all input rows form one group.

### Aggregate

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
array_unique_agg(value)
```

### Window

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
array_unique_agg(value) OVER ([PARTITION BY key] [ORDER BY ordering_key] [ROWS frame])
```

* Use a frame that includes all rows in the group or starts at the first row (`UNBOUNDED PRECEDING`). Sliding frames that drop earlier rows are not supported. RANGE frames with a numeric or time offset are not supported.

## Arguments

### Aggregate and window

| Name | Type | Required | Description |
| - | - | - | - |
| value | BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY, MAP or STRUCT | Yes | Non-NULL values to collect once. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: ARRAY\<same SQL type as value>
* NULL behavior: NULL values are ignored. The array itself is non-NULL.
* Empty input: Returns an empty array for an empty global aggregate or all-NULL frame.
* Shape: A one-dimensional array containing each non-NULL input value once.
* Ordering: Element order is unspecified; sort the output if ordered presentation is required.

## Properties

| Property | Value |
| - | - |
| Deterministic | Partial (Set contents are deterministic, but array element ordering is unspecified.) |
| Supports window usage | Partial (Use all rows in the group, or a frame starting at its first row.) |
| Supports window frames | Partial (The frame must start at the first row in the group. See Syntax.) |
| Exact result | Yes |

## Usage notes

* Duplicate and NULL values are removed automatically. DISTINCT is not needed.
* 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

### Duplicate and NULL values

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (1), (1), (CAST(NULL AS INTEGER))) SELECT array_unique_agg("value") AS result FROM t;
```

| result |
| - |
| \[1] |

### All NULL values

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH t("value") AS (VALUES (CAST(NULL AS INTEGER))) SELECT array_unique_agg("value") AS result FROM t;
```

| result |
| - |
| \[] |

## Limitations

* Use a frame that includes all rows in the group or starts at the first row (`UNBOUNDED PRECEDING`). Sliding frames that drop earlier rows are not supported. RANGE frames with a numeric or time offset are not supported.
* WITHIN GROUP does not guarantee ordered output for this function. Sort the returned array when you need a particular order.


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