Last updated on
MAP_ALL
Description
Tests every entry in a map with a lambda expression and returns whether all entries satisfy the specified condition. The lambda receives the key and value of each entry.
Syntax
MAP_ALL((<key>, <value>) -> <predicate>, <map>)
Parameters
| Parameter | Description |
|---|---|
<key> | The lambda parameter representing the key of a map entry. |
<value> | The lambda parameter representing the value of a map entry. |
<predicate> | A Boolean expression evaluated for each map entry. |
<map> | A MAP<K, V> expression. |
Return Value
Returns a BOOLEAN value.
- Returns
FALSEif the predicate returnsFALSEfor any entry. - Returns
TRUEif the predicate returnsTRUEfor every entry, including when the map is empty. - Returns
NULLif no entry returnsFALSEand at least one entry returnsNULL. - If
<map>isNULL, returnsNULL.
Examples
SELECT map_all((k, v) -> v >= 10, map(1, 10, 2, 20)) AS result;
+--------+
| result |
+--------+
| 1 |
+--------+
SELECT map_all((k, v) -> v > 10, map(1, 10, 2, 20)) AS result;
+--------+
| result |
+--------+
| 0 |
+--------+
SELECT map_all((k, v) -> CAST(NULL AS BOOLEAN), map(1, 10)) AS result;
+--------+
| result |
+--------+
| NULL |
+--------+
SELECT map_all((k, v) -> v > 0, CAST(NULL AS MAP<INT, INT>)) AS result;
+--------+
| result |
+--------+
| NULL |
+--------+