Skip to main content
sim computes the cosine similarity between two vectors for each row and returns a column of DOUBLE scores. similarity is an equivalent alias.

Signature

Either vector can be a column or a constant, such as one query vector compared with every row.

Rank rows against one query

Return type

DOUBLE, from -1 to 1.

Behavior

  • A null vector, a vector with a null element, or a zero-magnitude vector returns null.
  • Integer and floating-point elements are supported. DECIMAL elements are not.