Skip to main content
VeloDB Cloud 4.x·Apache Doris 3.x·"Since X.Y" tags refer to Doris versionsversion mapping →

ARRAY_SIZE

Description​

Count the number of elements in an array

Aliases​

  • SIZE
  • CARDINALITY

Syntax​

ARRAY_SIZE(<arr>) 

Parameters​

ParameterDescription
<arr>The array to be calculated

Return Value​

Returns the number of elements in the array. If the input array is NULL, it returns NULL.

Example​

SELECT ARRAY_SIZE(['a', 'b', 'c']),ARRAY_SIZE(NULL),ARRAY_SIZE([]);
+------------------------------+---------------------+-----------------+
| cardinality(['a', 'b', 'c']) | cardinality(NULL) | cardinality([]) |
+------------------------------+---------------------+-----------------+
| 3 | NULL | 0 |
+------------------------------+---------------------+-----------------+