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
Vector Analysis Functions
| Function | Description | Example |
|---|---|---|
| VECTOR_NORM | Calculates the L2 norm (magnitude) of a vector | VECTOR_NORM([1,2,3]::VECTOR(3)) |
| VECTOR_DIMS | Returns the dimensionality of a vector | VECTOR_DIMS([1,2,3]::VECTOR(3)) |
Distance Functions Comparison
| Function | Description | Range | Best For | Use Cases |
|---|---|---|---|---|
| COSINE_DISTANCE | Cosine 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 and absolute differences are important | • Image similarity • Geographical data • Anomaly detection • Feature-based clustering |
| INNER_PRODUCT | Dot product of two vectors | (-∞, ∞) | When both magnitude and direction are important | • Neural networks • Machine learning • Physics calculations • Vector projections |
