ARRAY functions

Updated at:

MaxCompute supports four complex data types: ARRAY, MAP, STRUCT, and JSON. This topic describes ARRAY functions and their features.

Function

Description

ALL_MATCH

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

ANY_MATCH

Checks whether an ARRAY contains elements that meet a specified condition.

ARRAY

Constructs an ARRAY by using specified values.

ARRAY_CONTAINS

Checks whether a specified ARRAY contains a specified value.

ARRAY_DISTINCT

Removes duplicate elements from an ARRAY.

ARRAY_EXCEPT

Finds elements that exist in ARRAY A but not in ARRAY B, removes duplicate elements, and returns the result as an ARRAY.

ARRAY_INTERSECT

Returns the intersection of two ARRAYs.

ARRAY_JOIN

Concatenates elements in an ARRAY by using a specified separator.

ARRAY_MAX

Returns the maximum value in an ARRAY.

ARRAY_MIN

Returns the minimum value in an ARRAY.

ARRAY_NORMALIZE

Returns an ARRAY whose elements are normalized based on a 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 specified elements from an ARRAY.

ARRAY_REPEAT

Returns an ARRAY in which a specified element is repeated a specified number of times.

ARRAY_SORT

Sorts elements in an ARRAY.

ARRAY_UNION

Returns the union of two ARRAYs and removes duplicate elements.

ARRAYS_OVERLAP

Checks whether two ARRAYs contain the same elements.

ARRAYS_ZIP

Merges multiple ARRAYs.

COMBINATIONS

Returns an ARRAY that consists of n-grams of the input ARRAY elements.

CONCAT

Concatenates ARRAYs or strings.

EXPLODE

A UDTF that converts one row of data into multiple rows.

FILTER

Filters elements in an ARRAY.

FLATTEN

Converts an ARRAY of ARRAYs into a single ARRAY.

INDEX

Returns the element at a specified position in an ARRAY.

NGRAMS

Returns an ARRAY of n-grams for the specified ARRAY elements.

POSEXPLODE

Expands a specified ARRAY into multiple rows, with each row containing the index (starting from 0) and the element value.

REVERSE

Returns an ARRAY with elements in reverse order.

SEQUENCE

Generates an ARRAY that contains specified elements based on an expression.

SHUFFLE

Returns an ARRAY with elements in random order.

SIZE

Returns the number of elements in an ARRAY.

SLICE

Slices an ARRAY and returns elements from a specified position for a specified length.

SORT_ARRAY

Sorts elements in a specified ARRAY.

TRANSFORM

Transforms elements in an ARRAY.

ZIP_WITH

Merges two ARRAYs element by element based on positions.