forall
function
Applies to: Databricks SQL Databricks Runtime
Tests whether func
holds for all elements in the array.
Syntax
forall(expr, func)
Arguments
expr
: An ARRAY expression.func
: A lambda function returning a BOOLEAN.
Returns
A BOOLEAN.
The lambda function uses one parameter passing an element of the array.
Examples
> SELECT forall(array(1, 2, 3), x -> x % 2 == 0);
false
> SELECT forall(array(2, 4, 8), x -> x % 2 == 0);
true
> SELECT forall(array(1, NULL, 3), x -> x % 2 == 0);
false
> SELECT forall(array(2, NULL, 8), x -> x % 2 == 0);
NULL
Related functions
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for