Getting started
User guides
Administration guides
Reference guides
Resources
Updated May 13, 2022
Send us feedback
filter
Filters the array in expr using the function func.
expr
func
filter(expr, func)
expr: An ARRAY expression.
func: A lambda function.
The result is of the same type as expr.
The lambda function may use one or two parameters where the first parameter represents the element and the second the index into the array.
> SELECT filter(array(1, 2, 3), x -> x % 2 == 1); [1,3] > SELECT filter(array(0, 2, 3), (x, i) -> x > i); [2,3] > SELECT filter(array(0, null, 2, 3, null), x -> x IS NOT NULL); [0,2,3]
exists function (Databricks SQL)
forall function (Databricks SQL)
map_filter function (Databricks SQL)