JingsongLi commented on code in PR #1522:
URL: https://github.com/apache/paimon-rust/pull/1522#discussion_r4664999871


##########
crates/paimon/src/table/de_vector_read.rs:
##########
@@ -3646,6 +3704,8 @@ struct TaskVectorSearch {
     limit: usize,
     field: String,
     options: HashMap<String, String>,
+    #[serde(default)]
+    expected_distance_metric: Option<String>,

Review Comment:
   [P1] Enforce the expected metric when merging scheduled search results. The 
task keeps its existing kind and version, so an older worker can ignore this 
optional field and return L2 scores for a query that requires cosine. The 
coordinator already receives the persisted metric, but its check only uses the 
existing query options and the MultiVector default. With a fully indexed L2 
table, dropping this field in a test executor produced a successful result with 
scores [1.0, 0.5]. Local execution rejected the same query. Compare the 
worker-reported metric with the expected metric before merging, or version the 
work so a worker that cannot enforce it rejects the task.



##########
crates/paimon/src/vector_search.rs:
##########
@@ -72,6 +74,25 @@ impl VectorSearch {
         self
     }
 
+    pub fn with_expected_distance_metric(mut self, metric: String) -> Self {
+        self.expected_distance_metric = Some(metric);
+        self
+    }
+
+    pub(crate) fn ensure_distance_metric(&self, actual: &str) -> 
crate::Result<()> {
+        if let Some(expected) = &self.expected_distance_metric {
+            if expected != actual {

Review Comment:
   [P2] Use the same metric spelling rules for Rust callers on both search 
routes. `with_expected_distance_metric("Inner-Product")` goes through the PK 
metric parser and accepts this alias, while the Data Evolution route compares 
it verbatim and rejects the same persisted metric. Use the same parser on both 
routes.



##########
docs/src/c-binding.md:
##########
@@ -520,6 +520,13 @@ and ranges. Combine predicates with `paimon_predicate_and`,
 
 ## Vector Scan, Plan, and Read
 
+`paimon_vector_search_builder_execute_scored` returns global row IDs and scores
+as Arrow Int64 and Float32 columns named `row_id` and `score`. An inclusive
+interval supplied to `paimon_vector_search_builder_with_row_range` intersects

Review Comment:
   [P2] Document the scalar fallback for scored searches. Without a usable 
scalar index, the range restricts the ANN candidates first, then the predicate 
filters the candidate shortlist. A selective predicate can leave fewer than K 
hits even when more matching rows exist in-range, as the SQL guide already 
describes. Please also state that `execute_scored` requires global row IDs. It 
errors for primary-key results, whose positions are file-local.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to