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

# `flatten` 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

Transforms an array of arrays into a single array.

## Syntax

```
flatten(expr)
```

## Arguments

* `expr`: An ARRAY of ARRAY expression.

## Returns

The result matches the type of the nested arrays within `expr`.

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 flatten(array(array(1, 2), array(3, 4)));
 [1,2,3,4]
```

## Related functions
