map_filter function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Filters entries in the map in expr using the function func.

Syntax

map_filter(expr, func)

Arguments

  • expr: A MAP expression.
  • func: A lambda function with two parameters returning a BOOLEAN. The first parameter takes the key the second parameter takes the value.

Returns

The result is the same type as expr.

Examples

> SELECT map_filter(map(1, 0, 2, 2, 3, -1), (k, v) -> k > v);
  {1 -> 0, 3 -> -1}