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 and V in map<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

Data of the MAP type is returned.

Example

-- {-30:100, 20:50} is returned. 
select map_filter(map(10, -20, 20, 50, -30, 100, 21, null), (k, v) -> (k+v) > 10);