v.21.2New Features

Add Functions for Map Data Type: Check Key Existence, Retrieve Keys and Values

Add three functions for map data type: 1. mapContains(map, key) to check weather map.keys include the second parameter key. 2. mapKeys(map) return all the keys in Array format 3. mapValues(map) return all the values in Array format. #18788 (hexiaoting).
Introduces three new functions for the map data type: mapContains(map, key) to check if a key exists in the map, mapKeys(map) to return all keys as an array, and mapValues(map) to return all values as an array.

Why it matters

These functions enhance working with map data types by providing convenient ways to query the presence of keys and extract all keys or values, simplifying data manipulation and improving query expressiveness in ClickHouse.

How to use it

Use the functions directly in your SQL queries. For example:

SELECT mapContains(my_map_column, 'key') FROM my_table;
SELECT mapKeys(my_map_column) FROM my_table;
SELECT mapValues(my_map_column) FROM my_table;