Returns `true` when every projection item is either: - a plain column reference to the surrogate/PK column (`id` or `document_id`), or - a `vector_distance(...)` function call (any alias). Anything else — a payload field, `*`, or an unrecognised expression — returns `false`.
(projection: &[Projection])
| 26 | /// |
| 27 | /// Anything else — a payload field, `*`, or an unrecognised expression — returns `false`. |
| 28 | fn is_pure_vector_projection(projection: &[Projection]) -> bool { |
| 29 | if projection.is_empty() { |
| 30 | return false; |
| 31 | } |
| 32 | for item in projection { |
| 33 | match item { |
| 34 | Projection::Column(name) => { |
| 35 | let lower = name.to_ascii_lowercase(); |
| 36 | if lower != "id" && lower != "document_id" { |
| 37 | return false; |
| 38 | } |
| 39 | } |
| 40 | Projection::Computed { expr, .. } => { |
| 41 | // Accept any of the three vector distance function names. |
| 42 | let SqlExpr::Function { name, .. } = expr else { |
| 43 | return false; |
| 44 | }; |
| 45 | if !name.eq_ignore_ascii_case("vector_distance") |
| 46 | && !name.eq_ignore_ascii_case("vector_cosine_distance") |
| 47 | && !name.eq_ignore_ascii_case("vector_neg_inner_product") |
| 48 | { |
| 49 | return false; |
| 50 | } |
| 51 | } |
| 52 | Projection::Star | Projection::QualifiedStar(_) => return false, |
| 53 | } |
| 54 | } |
| 55 | true |
| 56 | } |
| 57 | |
| 58 | /// Plan a SELECT query. |
| 59 | pub fn plan_query( |