Returns all values in Map a as an array.
Syntax
array<V> map_values(map<K, V> <a>)
Parameters
a: required. This parameter specifies a map. K
and V
in map<K, V>
specify the keys and values of a map.
Return value
A value of the ARRAY type is returned. If the input map is null, null is returned.
Examples
Return all keys in a map based on the data in the t_table_map
table that contains the c1 (BIGINT) and t_map (MAP<STRING,BIGINT>)
columns. Data in the table:
+------------+-------+
| c1 | t_map |
+------------+-------+
| 1000 | {k11:86, k21:15} |
| 1001 | {k12:97, k22:2} |
| 1002 | {k13:99, k23:1} |
+------------+-------+
Sample statement:
-- Return values in the t_map column as an array.
select c1,map_values(t_map) from t_table_map;
-- The following result is returned:
+------------+------+
| c1 | _c1 |
+------------+------+
| 1000 | [86, 15] |
| 1001 | [97, 2] |
| 1002 | [99, 1] |
+------------+------+
Related functions
MAP_VALUES 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.