@@ -225,6 +225,52 @@ extension Expression {
225225 func bitRightShift( _ numberExpression: Expression ) -> FunctionExpression {
226226 return FunctionExpression ( " bit_right_shift " , [ self , numberExpression] )
227227 }
228+
229+ /// Calculates the Manhattan (L1) distance between this vector expression and another vector
230+ /// expression.
231+ /// Assumes both `self` and `other` evaluate to Vectors.
232+ ///
233+ /// - Note: This API is in beta.
234+ ///
235+ /// ```swift
236+ /// // Manhattan distance between "vector1" field and "vector2" field
237+ /// Field("vector1").manhattanDistance(Field("vector2"))
238+ /// ```
239+ ///
240+ /// - Parameter expression: The other vector as an `Expr` to compare against.
241+ /// - Returns: A new `FunctionExpression` representing the Manhattan distance.
242+ func manhattanDistance( _ expression: Expression ) -> FunctionExpression {
243+ return FunctionExpression ( " manhattan_distance " , [ self , expression] )
244+ }
245+
246+ /// Calculates the Manhattan (L1) distance between this vector expression and another vector
247+ /// literal (`VectorValue`).
248+ /// Assumes `self` evaluates to a Vector.
249+ /// - Note: This API is in beta.
250+ /// ```swift
251+ /// let referencePoint = VectorValue(vector: [5.0, 10.0])
252+ /// Field("dataPoint").manhattanDistance(referencePoint)
253+ /// ```
254+ /// - Parameter vector: The other vector as a `VectorValue` to compare against.
255+ /// - Returns: A new `FunctionExpression` representing the Manhattan distance.
256+ func manhattanDistance( _ vector: VectorValue ) -> FunctionExpression {
257+ return FunctionExpression ( " manhattan_distance " , [ self , Helper . sendableToExpr ( vector) ] )
258+ }
259+
260+ /// Calculates the Manhattan (L1) distance between this vector expression and another vector
261+ /// literal (`[Double]`).
262+ /// Assumes `self` evaluates to a Vector.
263+ /// - Note: This API is in beta.
264+ ///
265+ /// ```swift
266+ /// // Manhattan distance between "point" field and a target point
267+ /// Field("point").manhattanDistance([10.0, 20.0])
268+ /// ```
269+ /// - Parameter vector: The other vector as `[Double]` to compare against.
270+ /// - Returns: A new `FunctionExpression` representing the Manhattan distance.
271+ func manhattanDistance( _ vector: [ Double ] ) -> FunctionExpression {
272+ return FunctionExpression ( " manhattan_distance " , [ self , Helper . sendableToExpr ( vector) ] )
273+ }
228274}
229275
230276public extension Expression {
@@ -690,18 +736,6 @@ public extension Expression {
690736 return FunctionExpression ( " euclidean_distance " , [ self , Helper . sendableToExpr ( vector) ] )
691737 }
692738
693- func manhattanDistance( _ expression: Expression ) -> FunctionExpression {
694- return FunctionExpression ( " manhattan_distance " , [ self , expression] )
695- }
696-
697- func manhattanDistance( _ vector: VectorValue ) -> FunctionExpression {
698- return FunctionExpression ( " manhattan_distance " , [ self , Helper . sendableToExpr ( vector) ] )
699- }
700-
701- func manhattanDistance( _ vector: [ Double ] ) -> FunctionExpression {
702- return FunctionExpression ( " manhattan_distance " , [ self , Helper . sendableToExpr ( vector) ] )
703- }
704-
705739 // MARK: Timestamp operations
706740
707741 func unixMicrosToTimestamp( ) -> FunctionExpression {
0 commit comments