Skip to main content

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

FunctionDescriptionExample
COSINE_DISTANCECalculates angular distance between vectors (range: 0-1)COSINE_DISTANCE([1,2,3], [4,5,6])
L1_DISTANCECalculates Manhattan (L1) distance between vectorsL1_DISTANCE([1,2,3], [4,5,6])
L2_DISTANCECalculates Euclidean (straight-line) distanceL2_DISTANCE([1,2,3], [4,5,6])

Vector Analysis Functions

FunctionDescriptionExample
INNER_PRODUCTCalculates the inner product (dot product) of two vectorsINNER_PRODUCT([1,2,3], [4,5,6])
VECTOR_NORMCalculates the L2 norm (magnitude) of a vectorVECTOR_NORM([1,2,3])
VECTOR_DIMSReturns the dimensionality of a vectorVECTOR_DIMS([1,2,3])

Distance Functions Comparison

FunctionDescriptionRangeBest ForUse Cases
COSINE_DISTANCEAngular distance between vectors[0, 1]When direction matters more than magnitude• Document similarity
• Semantic search
• Recommendation systems
• Text analysis
L1_DISTANCEManhattan (L1) distance between vectors[0, ∞)Robust to outliers• Feature comparison
• Outlier detection
• Grid-based pathfinding
• Clustering algorithms
L2_DISTANCEEuclidean (straight-line) distance[0, ∞)When magnitude matters• Image similarity
• Geographical data
• Anomaly detection
• Feature-based clustering

Vector Analysis Functions Comparison

FunctionDescriptionRangeBest ForUse Cases
INNER_PRODUCTDot product of two vectors(-∞, ∞)Measuring vector similarity and projections• Neural networks
• Machine learning
• Physics calculations
• Vector projections
VECTOR_NORML2 norm (magnitude) of a vector[0, ∞)Vector normalization and magnitude• Vector normalization
• Feature scaling
• Magnitude calculations
• Physics applications
VECTOR_DIMSNumber of vector dimensions[1, 4096]Vector validation and processing• Data validation
• Dynamic processing
• Debugging
• Compatibility checks
Explore Databend Cloud for FREE
Low-cost
Fast Analytics
Easy Data Ingestion
Elastic Scaling
Try it today