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

Function rewrite_arrow_distance

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

Rewrite all occurrences of `expr <-> expr` to `vector_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

11/// Returns `None` if no valid `<->` patterns are found outside string
12/// literals, quoted identifiers, or comments.
13pub(super) fn rewrite_arrow_distance(sql: &str) -> Option<String> {
14 rewrite_binary_op(sql, "<->", "vector_distance")
15}
16
17/// Extract the left operand before `<->`: a column name or dotted path.
18fn extract_left_operand(before: &str) -> Option<String> {

Callers 3

preprocessFunction · 0.85
basic_array_rewriteFunction · 0.85
rewrite_with_paramFunction · 0.85

Calls 1

rewrite_binary_opFunction · 0.85

Tested by 2

basic_array_rewriteFunction · 0.68
rewrite_with_paramFunction · 0.68