---
title: array_union function
description: Learn the syntax of the array\_union function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/array_union
---

# `array_union` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns an array of the elements in the union of `array1` and `array2` without duplicates.

## Syntax

```
array_union(array1, array2)
```

## Arguments

* `array1`: An ARRAY.
* `array2`: An ARRAY of the same type as `array1`.

## Returns

An ARRAY of the same type as `array`.

Databricks raises [COLLECTION\_SIZE\_LIMIT\_EXCEEDED](https://docs.databricks.com/aws/en/error-messages/collection-size-limit-exceeded-error-class.md) if the result exceeds the array size limit.

## Common error conditions

* [COLLECTION\_SIZE\_LIMIT\_EXCEEDED](https://docs.databricks.com/aws/en/error-messages/collection-size-limit-exceeded-error-class.md)

## Examples

```sql
> SELECT array_union(array(1, 2, 2, 3), array(1, 3, 5));
 [1,2,3,5]
```

## Related functions

* [`array_compact` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_compact.md)
* [`array_distinct` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_distinct.md)
* [`array_intersect` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_intersect.md)
* [`array_except` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_except.md)
* [`array_sort` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_sort.md)
* [`array_remove` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/array_remove.md)
* [`zip_with` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/zip_with.md)
