MAP_INSERT (Lakehouse v1)
Returns a new MAP consisting of the input MAP with a new key-value pair inserted (an existing key updated with a new value).
SQL Syntax
Section titled “SQL Syntax”MAP_INSERT( <map>, <key>, <value> [, <updateFlag> ] )Arguments
Section titled “Arguments”| Arguments | Description |
|---|---|
<map> | The input MAP. |
<key> | The new key to insert into the MAP. |
<value> | The new value to insert into the MAP. |
<updateFlag> | The boolean flag indicates whether an existing key can be overwritten. The default is FALSE. |
Return Type
Section titled “Return Type”Map.
SQL Examples
Section titled “SQL Examples”SELECT MAP_INSERT({'a':1,'b':2,'c':3}, 'd', 4);┌─────────────────────────────────────────┐│ map_insert({'a':1,'b':2,'c':3}, 'd', 4) │├─────────────────────────────────────────┤│ {'a':1,'b':2,'c':3,'d':4} │└─────────────────────────────────────────┘
SELECT MAP_INSERT({'a':1,'b':2,'c':3}, 'a', 5, true);┌───────────────────────────────────────────────┐│ map_insert({'a':1,'b':2,'c':3}, 'a', 5, TRUE) │├───────────────────────────────────────────────┤│ {'a':5,'b':2,'c':3} │└───────────────────────────────────────────────┘