github-actions[bot] commented on code in PR #68815:
URL: https://github.com/apache/doris/pull/68815#discussion_r4227385317


##########
be/src/format_v2/table/lance_reader.cpp:
##########
@@ -1078,6 +1103,17 @@ Status 
LanceTableReader::_configure_vector_search(LanceScanner* scanner,
         }
     }
 
+    if (vector.__isset.distance_lower_bound || 
vector.__isset.distance_upper_bound) {
+        const float lower = static_cast<float>(vector.distance_lower_bound);
+        const float upper = static_cast<float>(vector.distance_upper_bound);
+        // nearest() clears the range; install bounds only after setting the 
query vector.
+        if (lance_scanner_set_distance_range(
+                    scanner, vector.__isset.distance_lower_bound ? &lower : 
nullptr,
+                    vector.__isset.distance_upper_bound ? &upper : nullptr) != 
0) {

Review Comment:
   [P3] Preserve an absent upper bound for indexed searches. With only 
`distance_lower_bound=3.4028235E38`, this passes a null upper pointer, but the 
pinned Lance IVF_FLAT per-partition search replaces that null with `f32::MAX` 
and drops scores `>=` it 
([source](https://github.com/lance-format/lance/blob/68c12dfd7efe02f90ad2d7f3a239a7eb64884e57/rust/lance-index/src/vector/flat/index.rs#L203-L214)).
 A DOT query `[-FLT_MAX]` against an ordinary stored `[1.0]` has a finite 
`FLT_MAX` score, so an eligible row disappears when `query_parallelism>1` takes 
this indexed path; flat search retains it. Fix the pinned native filter to test 
upper-bound presence and cover lower-only indexed/flat parity at this endpoint.



##########
fe/fe-core/src/main/java/org/apache/doris/tablefunction/VectorSearchTableValuedFunction.java:
##########
@@ -64,10 +64,12 @@ public class VectorSearchTableValuedFunction extends 
LanceExternalSearchTableVal
     private static final String NPROBES = "nprobes";
     private static final String REFINE_FACTOR = "refine_factor";
     private static final String EF = "ef";
+    private static final String DISTANCE_LOWER_BOUND = "distance_lower_bound";
+    private static final String DISTANCE_UPPER_BOUND = "distance_upper_bound";
     private static final String USE_INDEX = "use_index";
     private static final Set<String> PROPERTIES = ImmutableSet.of(
             TABLE, COLUMN, QUERY_VECTOR, TOP_K, OFFSET, METRIC, FILTER,
-            NPROBES, REFINE_FACTOR, EF, USE_INDEX, QUERY_PARALLELISM);
+            NPROBES, REFINE_FACTOR, EF, USE_INDEX, QUERY_PARALLELISM, 
DISTANCE_LOWER_BOUND, DISTANCE_UPPER_BOUND);

Review Comment:
   [P2] Allow prepared statements to bind distance bounds. The new properties 
are rejected by `LogicalPlanBuilder.visitTableValuedFunction` because its 
placeholder allow-list still contains only `query_vector`, `top_k`, `offset`, 
and `filter`. Thus `PREPARE ... vector_search(..., 'distance_upper_bound'=?)` 
fails before this TVF can validate the bound, although the threshold can vary 
per EXECUTE without changing the result schema. Add both bound keys to the 
prepared-property binding path and test repeated EXECUTEs with different bounds.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to