Returns the largest element in Array a.
Syntax
T array_max(array<T> <a>)
Parameters
a: required. This parameter specifies an array. T
in array<T>
specifies the data type of the elements in the array.
The following data types are supported:
TINYINT, SMALLINT, INT, and BIGINT
FLOAT and DOUBLE
BOOLEAN
DECIMAL and DECIMALVAL
DATE, DATETIME, TIMESTAMP, IntervalDayTime, and IntervalYearMonth
STRING, BINARY, VARCHAR, and CHAR
ARRAY, STRUCT, and MAP
Return value
The largest element in Array a is returned. The return value varies based on the following rules:
If Array a is null, null is returned.
If an element in Array a is null, the null element is not involved in the operation.
Examples
-- The return value is 20.
select array_max(array(1, 20, null, 3));
Related functions
ARRAY_MAX is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.