Vector Functions
This section provides reference information for vector functions in Databend. These functions enable comprehensive vector operations including distance calculations, similarity measurements, and vector analysis for machine learning applications, vector search, and AI-powered analytics.
Distance Functions
Function | Description | Example |
---|---|---|
COSINE_DISTANCE | Calculates angular distance between vectors (range: 0-1) | COSINE_DISTANCE([1,2,3], [4,5,6]) |
L1_DISTANCE | Calculates Manhattan (L1) distance between vectors | L1_DISTANCE([1,2,3], [4,5,6]) |
L2_DISTANCE | Calculates Euclidean (straight-line) distance | L2_DISTANCE([1,2,3], [4,5,6]) |
Vector Analysis Functions
Function | Description | Example |
---|---|---|
INNER_PRODUCT | Calculates the inner product (dot product) of two vectors | INNER_PRODUCT([1,2,3], [4,5,6]) |
VECTOR_NORM | Calculates the L2 norm (magnitude) of a vector | VECTOR_NORM([1,2,3]) |
VECTOR_DIMS | Returns the dimensionality of a vector | VECTOR_DIMS([1,2,3]) |
Distance Functions Comparison
Function | Description | Range | Best For | Use Cases |
---|---|---|---|---|
COSINE_DISTANCE | Angular distance between vectors | [0, 1] | When direction matters more than magnitude | • Document similarity • Semantic search • Recommendation systems • Text analysis |
L1_DISTANCE | Manhattan (L1) distance between vectors | [0, ∞) | Robust to outliers | • Feature comparison • Outlier detection • Grid-based pathfinding • Clustering algorithms |
L2_DISTANCE | Euclidean (straight-line) distance | [0, ∞) | When magnitude matters | • Image similarity • Geographical data • Anomaly detection • Feature-based clustering |
Vector Analysis Functions Comparison
Function | Description | Range | Best For | Use Cases |
---|---|---|---|---|
INNER_PRODUCT | Dot product of two vectors | (-∞, ∞) | Measuring vector similarity and projections | • Neural networks • Machine learning • Physics calculations • Vector projections |
VECTOR_NORM | L2 norm (magnitude) of a vector | [0, ∞) | Vector normalization and magnitude | • Vector normalization • Feature scaling • Magnitude calculations • Physics applications |
VECTOR_DIMS | Number of vector dimensions | [1, 4096] | Vector validation and processing | • Data validation • Dynamic processing • Debugging • Compatibility checks |