size (cardinality)
description
Syntax
BIGINT size(ARRAY<T> arr)
BIGINT cardinality(ARRAY<T> arr)
返回数组中元素数量,如果输入数组为NULL,则返回NULL
notice
仅支持向量化引擎中使用
example
mysql> set enable_vectorized_engine=true;
mysql> select k1,k2,size(k2) from array_test;
+------+-----------+------------+
| k1 | k2 | size(`k2`) |
+------+-----------+------------+
| 1 | [1, 2, 3] | 3 |
| 2 | [] | 0 |
| 3 | NULL | NULL |
+------+-----------+------------+
mysql> select k1,k2,cardinality(k2) from array_test;
+------+-----------+-------------------+
| k1 | k2 | cardinality(`k2`) |
+------+-----------+-------------------+
| 1 | [1, 2, 3] | 3 |
| 2 | [] | 0 |
| 3 | NULL | NULL |
+------+-----------+-------------------+
keywords
SIZE, CARDINALITY