All Products
Search
Document Center

MaxCompute:SIZE

Last Updated:Mar 25, 2026

Returns the number of elements in an array or the number of key-value pairs in a map.

Usage notes

  • Array input: Returns the number of elements in the array.

  • Map input: Returns the number of key-value pairs in the map.

Syntax

int size(array<T> <a>)
int size(map<K, V> <b>)

Parameters

ParameterRequiredDescription
aYesAn array. T specifies the data type of the elements. Elements can be of any data type.
bYesA map. K and V specify the data types of the keys and values.

Return value

Returns a value of the INT type.

Examples

Example 1: Count the elements in array('a','b').

-- Returns 2.
SELECT size(array('a','b'));

Example 2: Count the key-value pairs in map('a',123,'b',456).

-- Returns 2.
SELECT size(map('a',123,'b',456));

Related functions

SIZE is a complex type function. For more information about functions that process ARRAY, MAP, STRUCT, and JSON data, see Complex type functions.