MAP_VALUES

Description

The MAP_VALUES function is used to extract all the values from the input key-value map and return an array containing these values.

Syntax

MAP_VALUES(map<K, V>)

Parameter Description

  • map<K, V>: The input key-value mapping, where K represents the type of the key and V represents the type of the value.

Return Type

This function returns an array, where the element type in the array is the same as the value type V of the input mapping.

Usage Example

Example 1: Extracting values from a string key-value mapping

SELECT MAP_VALUES(map('苹果', 5, '香蕉', 3, '橘子', 8));

Return Results:

[5, 3, 8]

Example 2: Extracting values from complex type key-value mappings

SELECT MAP_VALUES(map('id', 101, 'name', '张三', 'age', 25));

Return Results:

[101, null, 25]

Example 3: Extracting values from an empty map

SELECT MAP_VALUES(map());

Return Results:

[]