Categories:

Semi-structured and structured data functions (Map)

MAP_DELETE

Returns a MAP based on an existing MAP with one or more keys removed..

Syntax

MAP_DELETE( <map>, <key1> [, <key2>, ... ] )
Copy

Arguments

map

The map that contains the key to remove.

keyN

The key to be omitted from the returned map.

Returns

Returns a MAP that contains the contents of the input (source) map with one or more keys removed.

Usage notes

  • The type of the key expression must match the type of the map’s key. If the type is VARCHAR, then the types can be different lengths.

  • Key values that are not found in the map are ignored.

Examples

Remove two key-value pairs from a map containing three key-value pairs:

SELECT MAP_DELETE({'a':1,'b':2,'c':3}::MAP(VARCHAR,NUMBER),'a','b');
Copy
+--------------------------------------------------------------+
| MAP_DELETE({'A':1,'B':2,'C':3}::MAP(VARCHAR,NUMBER),'A','B') |
|--------------------------------------------------------------|
| {                                                            |
|   "c": 3                                                     |
| }                                                            |
+--------------------------------------------------------------+
Language: English