VECTOR
Syntax
- scalar type is the element type in the vector, optional, the default value is float type. Supports tinyint/int/float
- dimension: only specifies the dimension
Example:
Create Vector:
Usage Restrictions
- The current version of the vector type does not support comparison operations, so it cannot be used in
ORDER BY
orGROUP BY
clauses. - The current client does not implement the vector type, but it is supported in the SQL engine. Therefore, when you execute a select statement with a vector type in the result, an error will occur: Unsupported data type: VECTOR_TYPE
Vector Type Conversion
Vector types support conversion to and from array types, as well as conversion from string types to vector types:
- Implicit Conversion: In most cases, vector types can be directly converted to array types, trying to keep the element types unchanged.
- Array to Vector: Array types can also be converted to vector types, but the array length must match the vector dimension. If they do not match, the conversion result will be
NULL
. - String to Vector: Strings in the format
'[1, 2, 3]'
can be converted to vector types (extra spaces will be ignored).
Performance Tip: For medium to high dimensions (dimension >= 128) vectors, using cast('[1,2,3,4]' as vector(4))
is slightly more efficient than vector(1,2,3,4)
.
Example: