Calculates the taxicab distance between numeric array expressions. It can be used to query embedding vectors that are most similar (for example, have the lowest distance) to a given vector.
vectorL1Distance(firstExpression, secondExpression)
The data type of the returned value is double. Returns null for arrays of different lengths and arrays of other types.
data record(a = array(1, 1, 1), b = array(1, 2, 3)),record(a = array(1.0, 1.0, 1.0), b = array(1.0, 2.0, 3.0)),record(a = array(1, 2), b = array(1, 2)),record(a = array(1, 2), b = array(1, 2, 3)),record(a = array(1, 2), b = array(1, "foo"))| fields a, b, vectorL1Distance(a, b)
Query result:
Calculates the Euclidean distance between numeric array expressions. It can be used to query embedding vectors that are most similar (for example, have the lowest distance) to a given vector.
vectorL2Distance(firstExpression, secondExpression)
The data type of the returned value is double. Returns null for arrays of different lengths and arrays of other types.
data record(a = array(1, 1, 1), b = array(1, 2, 3)),record(a = array(1.0, 1.0, 1.0), b = array(1.0, 2.0, 3.0)),record(a = array(1, 2), b = array(1, 2)),record(a = array(1, 2), b = array(1, 2, 3)),record(a = array(1, 2), b = array(1, "foo"))| fields a, b, vectorL2Distance(a, b)
Query result:
Calculates the cosine distance between numeric array expressions. It can be used to query embedding vectors that are most similar (for example, have the lowest distance) to a given vector.
vectorCosineDistance(firstExpression, secondExpression)
The data type of the returned value is double. Returns null for arrays of different lengths and arrays of other types.
data record(a = array(1, 1, 1), b = array(1, 2, 3)),record(a = array(1.0, 1.0, 1.0), b = array(1.0, 2.0, 3.0)),record(a = array(1, 2), b = array(1, 2)),record(a = array(1, 2), b = array(1, 2, 3)),record(a = array(1, 2), b = array(1, "foo"))| fields a, b, vectorCosineDistance(a, b)
Query result:
Calculates the negative dot product between numeric array expressions. It can be used to query embedding vectors that are most similar to a given vector.
vectorInnerProductDistance(firstExpression, secondExpression)
The data type of the returned value is double. Returns null for arrays of different lengths and arrays of other types.
data record(a = array(1, 1, 1), b = array(1, 2, 3)),record(a = array(1.0, 1.0, 1.0), b = array(1.0, 2.0, 3.0)),record(a = array(1, 2), b = array(1, 2)),record(a = array(1, 2), b = array(1, 2, 3)),record(a = array(1, 2), b = array(1, "foo"))| fields a, b, vectorInnerProductDistance(a, b)
Query result: