VECTOR_NUM_ELEMENTS
Return the number of elements in a vector.
It is a scalar function.
Syntax
VECTOR_NUM_ELEMENTS(vector_expression)
Arguments
vector_expression
: An expression that evaluates to a vector. The vector must be encoded as a blob containing packed single-precision or double-precision floating-point numbers in little-endian byte order.
Return Type
An integer or a null value.
Remarks
A vector can be of any length, but the input blob length must be divisible by the packed vector element size (1, 2, 4 or 8 bytes, depending on the vector element).
You can specify the datatype of the vector elements in which this operation is performed on the vector by adding a suffix to the function. Omitting the suffix from the function is equivalent to suffixing it with _F32
. All operations are done using the specified datatype. The following table lists the suffixes and their datatype.
Suffix | Datatype |
---|---|
| 8-bit signed integer |
| 16-bit signed integer |
| 32-bit signed integer |
| 64-bit signed integer |
| 32-bit floating-point number (IEEE standard format) |
| 64-bit floating-point number (IEEE standard format) |
Examples
CREATE TABLE vne_t (x BLOB); INSERT INTO vne_t VALUES (JSON_ARRAY_PACK('[4,3,1,5,2]'));
SELECT (VECTOR_NUM_ELEMENTS(x)) AS x from vne_t; **** +---+ | x | +---+ | 5 | +---+