VECTOR_ SUBVECTOR
On this page
Derives a vector expression from another vector expression.
It is a scalar function.
Syntax
VECTOR_SUBVECTOR(vector_expression, start_position, length)
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. -
start_
position: A 0-indexed number to determine where to start count. A positive index counts from the beginning of the vector. A negative index counts from the end of the vector. -
length: Length of required subvector
Return Type
A blob containing packed single-precision floating-point numbers in little-endian byte order.
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._
.
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 vsv_t (x BLOB);INSERT INTO vsv_t VALUES (JSON_ARRAY_PACK('[1,2,3,4,5]'));
SELECT JSON_ARRAY_UNPACK (VECTOR_SUBVECTOR(x,2,2)) AS x from vsv_t;
+-------+
| x |
+-------+
| [3,4] |
+-------+
SELECT JSON_ARRAY_UNPACK (VECTOR_SUBVECTOR(x,-2,2)) AS x from vsv_t;
+-------+
| x |
+-------+
| [4,5] |
+-------+
Last modified: March 1, 2023