Skip to main content
Returns an array of all the keys in the specified map. This function is supported from v2.5.

Syntax

Parameters

any_map: the MAP value from which you want to retrieve keys.

Return value

The return value is in the format of array<keyType>. The element type in the array matches the key type in the map. If the input is NULL, NULL is returned. If a key or value in the MAP value is NULL, NULL is processed as a normal value and contained in the result.

Examples

Query MAP data from a native table

From v3.1 onwards, the database supports defining MAP columns when you create a table. This example uses table test_map, which contains the following data:
Obtain all the keys from each row of the col_map column.

Query MAP data from data lake

This example uses Hive table hive_map, which contains the following data:
After a Hive catalog is created in your cluster, you can use this catalog and the map_keys() function to obtain all the keys from each row of the col_map column.