MAP
Description
Constructs a MAP<K, V> of a specific type using several groups of key-value pairs
Syntax
MAP( <key1> , <value1> [, <key2>, <value2> ... ])
Parameters
Optional Parameters
<key1>supports multiple types (refer toMAP<K, V>) to construct the key of the map<value1>to construct the value of the map
Variable Parameters
Supports multiple groups of key-value parameters
Return Value
Returns a specific type MAP<K, V> constructed from several groups of key-value pairs
Notes
- The number of parameters must be even (can be 0), otherwise an error will be reported.
- Key parameters can appear repeatedly, but Doris will remove duplicate keys.
- Keys can be NULL, and multiple NULL keys will be deduplicated.
Examples
-
Regular parameters
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 |+-----------------------+--------------------------+ -
No parameters case
select map();+-------+| map() |+-------+| {} |+-------+ -
NULL parameters
select map(null, 2, 3, null);+-----------------------+| map(null, 2, 3, null) |+-----------------------+| {null:2, 3:null} |+-----------------------+ -
If there are duplicate keys, they will be deduplicated
select map(1, 2, 2, 11, 1, 3, null, "null 1", null, "null 2");+--------------------------------------------------------+| map(1, 2, 2, 11, 1, 3, null, "null 1", null, "null 2") |+--------------------------------------------------------+| {2:"11", 1:"3", null:"null 2"} |+--------------------------------------------------------+