Filters the elements in map input based on the predicate condition.
Syntax
map<K, V> map_filter(map<K, V> <input>, function <K, V, boolean> <predicate>)
Parameters
input: required. A value of the MAP type.
K
andV
inmap<K, V>
specify the keys and values of a map.predicate: required. This parameter specifies the built-in function, user-defined function, or expression that is used to filter the elements in the map. The predicate condition consists of two input parameters that correspond to the keys and values in input. The output result is of the BOOLEAN type.
Return value
A value of the MAP type is returned.
Examples
-- The return value is {-30:100, 20:50}.
select map_filter(map(10, -20, 20, 50, -30, 100, 21, null), (k, v) -> (k+v) > 10);
In this example, the combination of a hyphen and a closing angle bracket (->)
is used. For more information about how to use the combination of a hyphen and a closing angle bracket (->)
in Lambda functions, see Lambda functions.
Related functions
MAP_FILTER is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.