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

ParameterDescriptionSupported input types
<function>A Lambda function used to check elements in the arrayA Lambda function returning BOOLEAN
<array>The array evaluated by the functionAny 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