All Products
Search
Document Center

MaxCompute:FLATTEN

Last Updated:Mar 25, 2026

Converts an ARRAY<ARRAY<T>> into a single ARRAY<T> by concatenating the elements of each sub-array in order.

Syntax

flatten(arrayOfArray)

Parameter

Parameter Type Description
arrayOfArray ARRAY<ARRAY<T>> An array whose elements are arrays. If the input parameters are not arrays of the ARRAY data type, an error is returned.

Return value

Returns an ARRAY<T> containing the concatenated elements of all sub-arrays, in order.

  • If arrayOfArray is null, returns null.

  • If the input parameters are not arrays of the ARRAY data type, an error is returned.

Examples

Flatten an array of arrays

SELECT flatten(array(array(1, 2), array(3, 4)));

Result:

[1, 2, 3, 4]

Return null when the input is null

SELECT flatten(null);

Result:

NULL

Related functions

FLATTEN is a complex type function. For more information about functions used to process ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.