VECTOR_ KTH_ ELEMENT
On this page
Returns the k-th element in a vector expression where k is 0-indexed.
It is a scalar function.
Syntax
VECTOR_KTH_ELEMENT(vector_expression, k)
Arguments
-
vector_
: An expression that evaluates to a vector.expression The vector must be encoded as a blob containing packed single-precision or double-precision floating-point numbers in little-endian byte order. -
k
: An 0-indexed number to determine which element in the vector to be returned.A positive index counts from the beginning of the vector. A negative index counts from the end of the vector.
Return Type
An element at the K-th position of the given vector.
Remarks
vector_
: An expression that evaluates to a vector.
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._
.
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 vke_t (x BLOB);INSERT INTO vke_t VALUES (JSON_ARRAY_PACK('[4,3,1,5,2]'));
SELECT (VECTOR_KTH_ELEMENT(x,2)) AS x from vke_t;
+---+
| x |
+---+
| 1 |
+---+
SELECT (VECTOR_KTH_ELEMENT(x,-3)) AS x from vke_t;
+---+
| x |
+---+
| 3 |
+---+
Last modified: February 28, 2023