v.21.2Improvements

Enable function length/empty/notEmpty for Map datatype

Enable function length/empty/notEmpty for datatype Map, which returns keys number in Map. #19530 (taiyang-li).
Enable length, empty, and notEmpty functions for Map datatype, allowing users to query the number of keys in a Map.

Why it matters

This feature adds support for the length, empty, and notEmpty functions on the Map datatype, enabling users to easily determine the size and emptiness of maps in their data. It solves the limitation that these functions previously did not work with Maps, enhancing data inspection and query flexibility.

How to use it

Users can directly apply the functions to Map columns as follows:

SELECT length(map_column), empty(map_column), notEmpty(map_column) FROM table

These functions will return the number of keys and boolean checks for emptiness of the Map datatype.