Skip to main content
Scalar function
Returns NULL for a NULL array, empty array or array containing only NULL elements. NULL elements are ignored.

Syntax

Scalar

Arguments

Type notation used below:
  • T is the array element type: BOOLEAN, TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE, DECIMAL(p, s), STRING, BINARY, DATE, TIME, TIMESTAMP, ARRAY or STRUCT.

Returns

  • Type: T
  • Possible values: The largest non-NULL element.
  • NULL behavior: Returns NULL for a NULL array, empty array or array containing only NULL elements. NULL elements are ignored.

Properties

Usage notes

  • NULL elements are ignored. An empty array or an array containing only NULL returns NULL. Floating-point ordering distinguishes positive and negative zero and different NaN values. STRING and BINARY values use lexicographic order; ARRAY and STRUCT values are compared by their elements or fields.
  • INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

Examples

Typical behavior

Compare date elements

Limitations

  • Elements must be comparable. MAP elements are not supported. The ordering of NaN and signed zero can differ from other SQL engines.
  • MAP elements, including MAP values nested inside compared elements, are outside the supported element types.
Last modified on October 15, 2026