A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/data-types-vector.html below:

Website Navigation


Vector data types | Snowflake Documentation

Vector data types

This topic describes the vector data types.

Data types

Snowflake supports a single vector data type, VECTOR.

Note

The VECTOR data type is only supported in SQL, the Python connector, and the Snowpark Python library. No other languages are supported.

VECTOR

With the VECTOR data type, Snowflake encodes and processes vectors efficiently. This data type supports semantic vector search and retrieval applications, such as RAG-based applications, and common operations on vectors in vector-processing applications.

To specify a VECTOR type, use the following syntax:

VECTOR( <type>, <dimension> )

Copy

Where:

Note

Direct vector comparisons (for example, v1 < v2) are byte-wise lexicographic and, although deterministic, won’t produce the results that you might expect from number comparisons. So although you can use VECTOR columns in ORDER BY clauses, for vector comparisons, use the vector similarity functions provided.

The following definitions are examples of valid vector definitions:

The following definitions are examples of invalid vector definitions:

Vector conversion

This section describes how to convert to and from a VECTOR value. For details about casting, see Data type conversion.

Converting a value to a VECTOR value

VECTOR values can be explicitly cast from the following types:

Converting a value from a VECTOR value

VECTOR values can be explicitly cast to the following types:

Loading and unloading vector data

Directly loading and unloading a VECTOR column isn’t supported. For VECTOR columns, you must load and unload data as an ARRAY and then cast it to a VECTOR when you use it. To learn how to load and unload ARRAY data types, see Introduction to Loading Semi-structured Data. A common use case for vectors is to generate a vector embedding.

The following example shows how to unload a table with a VECTOR column to an internal stage named mystage:

CREATE OR REPLACE TABLE myvectortable (a VECTOR(float, 3), b VECTOR(float, 3));
INSERT INTO myvectortable SELECT [1.1,2.2,3]::VECTOR(FLOAT,3), [1,1,1]::VECTOR(FLOAT,3);
INSERT INTO myvectortable SELECT [1,2.2,3]::VECTOR(FLOAT,3), [4,6,8]::VECTOR(FLOAT,3);

COPY INTO @mystage/unload/
  FROM (SELECT TO_ARRAY(a), TO_ARRAY(b) FROM myvectortable);

Copy

The following example shows how to load a table from a stage and then cast the ARRAY columns as VECTOR columns:

CREATE OR REPLACE TABLE arraytable (a ARRAY, b ARRAY);

COPY INTO arraytable
  FROM @mystage/unload/mydata.csv.gz;

SELECT a::VECTOR(FLOAT, 3), b::VECTOR(FLOAT, 3)
  FROM arraytable;

Copy

Examples

Construct a VECTOR by casting a constant ARRAY:

SELECT [1, 2, 3]::VECTOR(FLOAT, 3) AS vec;

Copy

Add a column with the VECTOR data type:

ALTER TABLE myissues ADD COLUMN issue_vec VECTOR(FLOAT, 768);

UPDATE TABLE myissues
  SET issue_vec = SNOWFLAKE.CORTEX.EMBED_TEXT_768('e5-base-v2', issue_text);

Copy

Limitations

The following limitations apply to VECTOR data:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4