All Products
Search
Document Center

MaxCompute:ARRAY_MAX

Last Updated:Mar 26, 2026

Returns the largest non-null element in an array. Returns null if the array is null. Null elements are skipped during comparison.

Syntax

T array_max(array<T> <a>)

The return type T is the same as the element type of the input array.

Parameters

Parameter Required Type Description
a Yes array<T> The input array. T is the data type of the array elements.

Supported element data types:

  • TINYINT, SMALLINT, INT, BIGINT

  • FLOAT, DOUBLE

  • BOOLEAN

  • DECIMAL, DECIMALVAL

  • DATE, DATETIME, TIMESTAMP, IntervalDayTime, IntervalYearMonth

  • STRING, BINARY, VARCHAR, CHAR

  • ARRAY, STRUCT, MAP

Return value

Returns the largest element of type T in the array. Returns null if the array is null. Null elements are skipped during comparison.

Examples

Basic usage — returns the largest non-null element:

-- Returns 20. The null element is skipped.
select array_max(array(1, 20, null, 3));

Related functions

ARRAY_MAX is a complex type function. For functions that process ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.