ARRAY functions

Updated at:
Copy as MD

MaxCompute supports four complex data types: ARRAY, MAP, STRUCT, and JSON. The following table lists the available ARRAY functions.

Function

Description

ALL_MATCH

Checks whether all elements in an ARRAY meet a specified condition.

ANY_MATCH

Checks whether any element in an ARRAY meets a specified condition.

ARRAY

Constructs an ARRAY with the given values.

ARRAY_CONTAINS

Checks whether the specified ARRAY contains the specified value.

ARRAY_DISTINCT

Removes duplicate elements from an ARRAY.

ARRAY_EXCEPT

Returns deduplicated elements present in ARRAY A but not in ARRAY B.

ARRAY_INTERSECT

Calculates the intersection of two ARRAYs.

ARRAY_JOIN

Joins ARRAY elements into a string with a specified delimiter.

ARRAY_MAX

Returns the maximum value in an ARRAY.

ARRAY_MIN

Returns the minimum value in an ARRAY.

ARRAY_NORMALIZE

Returns an array with elements normalized according to the specified p-norm.

ARRAY_POSITION

Returns the position of the first occurrence of a specified element in an ARRAY.

ARRAY_REDUCE

Aggregates elements in an ARRAY.

ARRAY_REMOVE

Removes the specified element from an ARRAY.

ARRAY_REPEAT

Returns an ARRAY with a specified element repeated N times.

ARRAY_SORT

Sorts elements in an ARRAY.

ARRAY_UNION

Returns the deduplicated union of two ARRAYs.

ARRAYS_OVERLAP

Checks whether two ARRAYs contain the same elements.

ARRAYS_ZIP

Merges multiple ARRAYs.

COMBINATIONS

Returns an array of N-tuples from input array elements.

CONCAT

Concatenates ARRAYs or strings.

EXPLODE

Converts a single row into multiple rows. This is a user-defined table-valued function (UDTF).

FILTER

Filters elements in an ARRAY.

FLATTEN

Flattens a nested array into a single array.

INDEX

Returns the element at a specified position in an ARRAY.

NGRAMS

Returns an array of n-grams for specified array elements.

POSEXPLODE

Expands an ARRAY into rows, each with a zero-based index column and an element column.

REVERSE

Returns an array with elements in reverse order.

SEQUENCE

Generates an array from an expression.

SHUFFLE

Returns an array with elements in random order.

SIZE

Returns the number of elements in an ARRAY.

SLICE

Returns a subarray of specified length starting from a given position.

SORT_ARRAY

Sorts elements in an array.

TRANSFORM

Transforms elements in an ARRAY.

ZIP_WITH

Merges two ARRAYs element-by-element by position.