Skip to main content

Map Functions

This section provides reference information for the map functions in Databend. Map functions allow you to create, manipulate, and extract information from map data structures (key-value pairs).

Map Creation and Combination

FunctionDescriptionExample
MAP_CATCombines multiple maps into a single mapMAP_CAT({'a':1}, {'b':2}){'a':1,'b':2}

Map Access and Information

FunctionDescriptionExample
MAP_KEYSReturns all keys from a map as an arrayMAP_KEYS({'a':1,'b':2})['a','b']
MAP_VALUESReturns all values from a map as an arrayMAP_VALUES({'a':1,'b':2})[1,2]
MAP_SIZEReturns the number of key-value pairs in a mapMAP_SIZE({'a':1,'b':2,'c':3})3
MAP_CONTAINS_KEYChecks if a map contains a specific keyMAP_CONTAINS_KEY({'a':1,'b':2}, 'a')TRUE

Map Modification

FunctionDescriptionExample
MAP_INSERTInserts a key-value pair into a mapMAP_INSERT({'a':1,'b':2}, 'c', 3){'a':1,'b':2,'c':3}
MAP_DELETERemoves a key-value pair from a mapMAP_DELETE({'a':1,'b':2,'c':3}, 'b'){'a':1,'c':3}

Map Transformation

FunctionDescriptionExample
MAP_TRANSFORM_KEYSApplies a function to each key in a mapMAP_TRANSFORM_KEYS({'a':1,'b':2}, x -> UPPER(x)){'A':1,'B':2}
MAP_TRANSFORM_VALUESApplies a function to each value in a mapMAP_TRANSFORM_VALUES({'a':1,'b':2}, x -> x * 10){'a':10,'b':20}

Map Filtering and Selection

FunctionDescriptionExample
MAP_FILTERFilters key-value pairs based on a predicateMAP_FILTER({'a':1,'b':2,'c':3}, (k,v) -> v > 1){'b':2,'c':3}
MAP_PICKCreates a new map with only specified keysMAP_PICK({'a':1,'b':2,'c':3}, ['a','c']){'a':1,'c':3}
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today