Returns the number of key-value pairs in a map.
Usage notes
An array as the input: Calculates the number of elements in Array a.
A map as the input: Calculates the number of key-value pairs in Map b.
Syntax
int size(array<T> <a>)
int size(map<K, V> <b> )
Parameters
a: required. This parameter specifies an array.
T
inarray<T>
specifies the data type of the elements in the array. The elements can be of any data type.b: required. This parameter specifies a map.
K
andV
inmap<K, V>
specify the keys and values of a map.
Return value
A value of the INT type is returned.
Examples
Example 1: Calculate the number of elements in
array('a','b')
. Sample statement:-- The return value is 2. select size(array('a','b'));
Example 2: Calculate the number of key-value pairs in
map('a',123,'b',456)
.-- The return value is 2. select size(map('a',123,'b',456));
Related functions
SIZE is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.