JSON_ARRAY_FILTER (Lakehouse v1)
Filters elements from a JSON array based on a specified Lambda expression, returning only the elements that satisfy the condition. For more information about Lambda expression, see Lambda Expressions.
SQL Syntax
Section titled “SQL Syntax”JSON_ARRAY_FILTER(<json_array>, <lambda_expression>)Return Type
Section titled “Return Type”JSON array.
SQL Examples
Section titled “SQL Examples”This example filters the array to return only the strings that start with the letter a, resulting in ["apple", "avocado"]:
SELECT JSON_ARRAY_FILTER( ['apple', 'banana', 'avocado', 'grape']::JSON, d -> d::String LIKE 'a%');
-[ RECORD 1 ]-----------------------------------json_array_filter(['apple', 'banana', 'avocado', 'grape']::VARIANT, d -> d::STRING LIKE 'a%'): ["apple","avocado"]