Skip to main content

ARRAY_FLATTEN

Introduced or updated: v1.2.762

Flattens a nested array into a single-dimensional array.

Syntax

ARRAY_FLATTEN(array)

Parameters

ParameterDescription
arrayThe nested array to flatten.

Return Type

Array (flattened).

Notes

This function works with both standard array types and variant array types.

Examples

Example 1: Flattening a Nested Array

SELECT ARRAY_FLATTEN([[1, 2], [3, 4]]);

Result:

[1, 2, 3, 4]

Example 2: Flattening a Variant Array

SELECT ARRAY_FLATTEN(PARSE_JSON('[["a", "b"], ["c", "d"]]'));

Result:

["a", "b", "c", "d"]
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