All Products
Search
Document Center

MaxCompute:ARRAY_MIN

Last Updated:Mar 26, 2026

Returns the smallest element in an array.

Syntax

T array_min(array<T> <a>)

Parameters

ParameterRequiredDescription
aYesThe input array. T specifies the data type of the array elements.

Supported types for T:

CategoryTypes
IntegerTINYINT, SMALLINT, INT, BIGINT
Floating-pointFLOAT, DOUBLE
BooleanBOOLEAN
DecimalDECIMAL, DECIMALVAL
Date and timeDATE, DATETIME, TIMESTAMP, IntervalDayTime, IntervalYearMonth
StringSTRING, VARCHAR, CHAR
BinaryBINARY
ComplexARRAY, STRUCT, MAP

Return value

Returns the smallest element in array a, with the same data type as the array elements.

ConditionReturn value
Array a is nullnull
Array a contains null elementsMinimum of the non-null elements; null elements are skipped

Usage notes

  • NULL handling: Null elements are skipped during comparison. Only non-null elements are evaluated. If the array itself is null, the function returns null.

Examples

Basic case with a null element:

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

Related functions

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