MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / rewrite_cosine_distance

Function rewrite_cosine_distance

nodedb-sql/src/parser/preprocess/vector_ops.rs:91–93  ·  view source on GitHub ↗

Rewrite all occurrences of `expr <=> expr` to `vector_cosine_distance(expr, expr)`. Handles: `column_name <=> ARRAY[...]`, `column <=> $param`, etc. Returns `None` if no valid `<=>` patterns are found outside string literals, quoted identifiers, or comments.

(sql: &str)

Source from the content-addressed store, hash-verified

89/// Returns `None` if no valid `<=>` patterns are found outside string
90/// literals, quoted identifiers, or comments.
91pub(super) fn rewrite_cosine_distance(sql: &str) -> Option<String> {
92 rewrite_binary_op(sql, "<=>", "vector_cosine_distance")
93}
94
95/// Rewrite all occurrences of `expr <#> expr` to `vector_neg_inner_product(expr, expr)`.
96///

Callers 2

preprocessFunction · 0.85

Calls 1

rewrite_binary_opFunction · 0.85

Tested by 1