MAP
Description
Constructs a Map<K, V>
of a specific type using some set of key-value pairs
Syntax
MAP( <key1> , <value1> [, <key2>,<value2> ... ])
Parameters
Parameter | Description |
---|---|
<key> | Constructing the key of the map |
<value> | Constructing the value of the map |
Return Value
Returns a specific type Map<K, V>
constructed from a number of key-value pairs
Example
select map(1, "100", 0.1, 2),map(1, "100", 0.1, 2)[1];
+-----------------------+--------------------------+
| map(1, "100", 0.1, 2) | map(1, "100", 0.1, 2)[1] |
+-----------------------+--------------------------+
| {1.0:"100", 0.1:"2"} | 100 |
+-----------------------+--------------------------+
- If there are duplicate keys, they will be deduplicated:
select map(1, 2, 2, 11, 1, 3);
+------------------------+
| map(1, 2, 2, 11, 1, 3) |
+------------------------+
| {2:11, 1:3} |
+------------------------+
There are two sets of parameters with the key 1 (1, 2 and 1, 3), only 1, 3 is retained.