ARRAY_SIZE
Descriptionβ
Count the number of elements in an array
Aliasesβ
- SIZE
- CARDINALITY
Syntaxβ
ARRAY_SIZE(<arr>)
Parametersβ
Parameter | Description |
---|---|
<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 | 1 | 0 |
+------------------------------+---------------------+-----------------+