Map Functions This section provides reference information for the map functions in TiDB Cloud Lake. Map functions allow you to create, manipulate, and extract information from map data structures (key-value pairs).
Map Creation and Combination Function Description Example MAP_CAT Combines multiple maps into a single map MAP_CAT({'a':1}, {'b':2}) → {'a':1,'b':2}
Function Description Example MAP_KEYS Returns all keys from a map as an array MAP_KEYS({'a':1,'b':2}) → ['a','b']MAP_VALUES Returns all values from a map as an array MAP_VALUES({'a':1,'b':2}) → [1,2]MAP_SIZE Returns the number of key-value pairs in a map MAP_SIZE({'a':1,'b':2,'c':3}) → 3MAP_CONTAINS_KEY Checks if a map contains a specific key MAP_CONTAINS_KEY({'a':1,'b':2}, 'a') → TRUE
Map Modification Function Description Example MAP_INSERT Inserts a key-value pair into a map MAP_INSERT({'a':1,'b':2}, 'c', 3) → {'a':1,'b':2,'c':3}MAP_DELETE Removes a key-value pair from a map MAP_DELETE({'a':1,'b':2,'c':3}, 'b') → {'a':1,'c':3}
Function Description Example MAP_TRANSFORM_KEYS Applies a function to each key in a map MAP_TRANSFORM_KEYS({'a':1,'b':2}, x -> UPPER(x)) → {'A':1,'B':2}MAP_TRANSFORM_VALUES Applies a function to each value in a map MAP_TRANSFORM_VALUES({'a':1,'b':2}, x -> x * 10) → {'a':10,'b':20}
Map Filtering and Selection Function Description Example MAP_FILTER Filters key-value pairs based on a predicate MAP_FILTER({'a':1,'b':2,'c':3}, (k,v) -> v > 1) → {'b':2,'c':3}MAP_PICK Creates a new map with only specified keys MAP_PICK({'a':1,'b':2,'c':3}, ['a','c']) → {'a':1,'c':3}