All Products
Search
Document Center

MaxCompute:SIZE

Last Updated:Mar 26, 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

  • a: Required. An array. T in array<T> specifies the element data type. Elements can be of any data type.

  • b: Required. A map. K and V in map<K, V> specify the key and value data types.

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.