All Products
Search
Document Center

MaxCompute:ALL_MATCH

Last Updated:Mar 26, 2026

Checks whether all elements in an array satisfy a predicate. Returns true if all elements satisfy the predicate or the array is empty, false if one or more elements do not satisfy it, and NULL if the predicate returns NULL for one or more elements while all other elements satisfy the predicate.

Syntax

boolean all_match(array<T> <a>, function<T, boolean> <predicate>)

Parameters

ParameterRequiredDescription
aYesThe array to evaluate. T is the data type of the elements and can be any supported type.
predicateYesA built-in function, user-defined function (UDF), or expression that evaluates each element. The input type must match the element type T.

Return value

ConditionReturn value
All elements satisfy the predicate, or the array is emptytrue
One or more elements do not satisfy the predicatefalse
An element is NULL and all other elements satisfy the predicateNULL

Examples

All examples use a lambda expression (->) as the predicate. For lambda syntax, see Lambda functions.

All elements satisfy the condition

-- Returns true
SELECT all_match(array(4, 5, 6), x -> x > 3);

Empty array

-- Returns true
SELECT all_match(array(), x -> x > 3);

Some elements do not satisfy the condition

-- Returns false
SELECT all_match(array(1, 2, -10, 100, -30), x -> x > 3);

Array contains NULL

-- Returns NULL: 10, 100, and 30 satisfy x > 3, but the NULL element causes the predicate to return NULL
SELECT all_match(array(10, 100, 30, null), x -> x > 3);

Related functions

ALL_MATCH 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.

In the preceding examples, the combination of a hyphen and a closing angle bracket (->) is used. For more information about how to use the combination of a hyphen and a closing angle bracket (->) in Lambda functions, see Lambda functions.