Snowflake 1
Snowflake 1
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:
Where:
<type> is the Snowflake data type of the elements, which can be 32-bit integers
or 32-bit floating-point numbers.
You can specify one of the following types:
INT
FLOAT
<dimension> is the dimension (length) of the vector. This must be a positive
integer value with a maximum value of 4096.
Note
Direct vector comparisons (e.g. v1 < v2) are byte-wise lexicographic and, while
deterministic, won’t produce results that you’d expect from number
comparisons. So while you can use VECTOR columns in ORDER BY clauses, for
vector comparisons, use the vector similarity functions provided.
VECTOR(FLOAT, 256)
VECTOR(INT, 16)
VECTOR(STRING, 256)
VECTOR(INT, -1)
Vector conversion
This section describes how to convert to and from a VECTOR value. For details on
casting, see Data type conversion.
The following example shows how to load a table from a stage and then cast the
ARRAY columns as VECTOR columns:
Examples
Construct a VECTOR by casting a constant ARRAY:
Limitations
There is limited language support for the VECTOR data type. Languages not
represented in this table are not supported.
Snowflake feature Python SQL
UDFs ✔ ✔
UDTFs ✔ ✔
Drivers/Connectors ✔ ✔
Snowpark API ✔