📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

ARRAY_FLATTEN



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"]

Was this page helpful?