FILTER
functionsupportedCore SQL functionsFilters an array based on the logic in a lambda expression.
Syntax
FILTER( <array> , <lambda_expression> )
Parameters
| Name | Required | Description |
|---|---|---|
array | required | The array that contains the elements to be filtered. The array can be semi-structured or structured. |
lambda_expression | required | A lambda expression that defines the filter condition on each array element. The lambda expression must have only one argument specified in the following syntax:Copy code <arg> [ <datatype> ] -> <expr> |
Returns
The return type of this function is an array of the same type as the input array. The returned array contains the elements for which the filter condition returns TRUE. If either argument is NULL, the function returns NULL without reporting an error.
Usage notes
- When the data type for the lambda argument is explicitly specified, the array element is coerced into the specified type before lambda invocation. For information about coercion, see Data type conversion.
- If the filter condition evaluates to NULL, the corresponding array element is filtered out.