ARRAY_FIRST

Returns the first element in the given array for which the given function returns true. The <function> parameter must be included.

Syntax

ARRAY_FIRST(<function>, <array>)

Parameters

Parameter Description Supported input types
<function> A Lambda function used to check elements in the array A Lambda function returning BOOLEAN
<array> The array evaluated by the function Any array

Return Type

The element type of <array>

Examples

The following example returns the first value in the levels array greater than 2:

SELECT
	ARRAY_FIRST(x -> x > 2, [ 1, 2, 4, 9 ]) AS levels;

Returns: 4