VECTOR_ORIGIN

The VECTOR_ORIGIN operator generates a vector in which all dimensions are zero, representing the origin point in an n-dimensional graph.

Parameters

VECTOR_ORIGIN can be used in two different ways. In the first case, a dimension count, element format, and or storage format are provided as parameters. In the second case, you provide only a vector column, from which the dimension and formats are derived.

Table 7-3 VECTOR_ORIGIN Parameters Using Dimension and Formats

Parameter Accepted Values Description
number_of_dimensions 1 to 65535 (inclusive)

An integer value that describes the number of dimensions of the vector to construct.

If the number of dimensions is not provided, or if it is provided as *, an error is thrown.

format

INT8,

FLOAT32,

FLOAT64,

BINARY,

or *

Optionally provide the element format. If it is not provided, or specified as *, the format will default to FLOAT32.

storage_format

DENSE or

SPARSE

Optionally provide the storage format. If not specified, or provided as *, the storage format will default to DENSE.

Table 7-4 VECTOR_ORIGIN Parameters Using a Vector Column

Parameter Accepted Values Description
vector_column The name of an existing vector column.

The dimension count, format, and storage format are derived from the provided vector column.

In the case that the vector column is defined with a flexible dimension count (*), and there is no index on top of the vector column, an error is thrown. If the vector column has a flexible dimension count but does have an associated index, the dimension count from the index is used. Otherwise, in the case that the vector column is defined with a valid dimension count, that number is used.

If the provided vector column has a flexible format, FLOAT32 is used by default. Otherwise, the format used to define the vector column is used.

The vector column's storage format, either DENSE or SPARSE is used.

Examples

-- Optional cleanup so the script can be rerun
DROP TABLE IF EXISTS vec_d_tab;
DROP TABLE IF EXISTS vec_s_tab;

-- vec_d_tab: dense vector column A with schema vector(3, float32)
CREATE TABLE vec_d_tab (
  a VECTOR(3, FLOAT32)
);

-- Insert two dense vectors.
-- Using vector_origin here creates a dense zero vector: [0,0,0]
INSERT INTO vec_d_tab VALUES (vector_origin(3, FLOAT32));
INSERT INTO vec_d_tab VALUES (vector_origin(3, FLOAT32));


-- vector_origin using the column metadata
SELECT vector_origin(a) AS dense_origin_from_column
FROM vec_d_tab;

-- vector_origin using explicit dense vector metadata
SELECT vector_origin(3, FLOAT32) AS dense_origin_from_type
FROM vec_d_tab;


-- vec_s_tab: sparse vector column A with schema vector(32000, float32, sparse)
CREATE TABLE vec_s_tab (
  a VECTOR(32000, FLOAT32, SPARSE)
);

-- Insert two sparse vectors.
-- Using vector_origin here creates an empty sparse zero vector: [32000,[],[]]
INSERT INTO vec_s_tab VALUES (vector_origin(32000, FLOAT32, SPARSE));
INSERT INTO vec_s_tab VALUES (vector_origin(32000, FLOAT32, SPARSE));


-- vector_origin using the sparse column metadata
SELECT vector_origin(a) AS sparse_origin_from_column
FROM vec_s_tab;

-- vector_origin using explicit sparse vector metadata
SELECT vector_origin(32000, FLOAT32, SPARSE) AS sparse_origin_from_type
FROM vec_s_tab;

Example results:

DENSE_ORIGIN_FROM_COLUMN
---------------------------------------------------------------------
[0,0,0]
[0,0,0]

DENSE_ORIGIN_FROM_TYPE
---------------------------------------------------------------------
[0,0,0]
[0,0,0]


SPARSE_ORIGIN_FROM_COLUMN
---------------------------------------------------------------------
[32000,[],[]]
[32000,[],[]]

SPARSE_ORIGIN_FROM_TYPE
---------------------------------------------------------------------
[32000,[],[]]
[32000,[],[]]