This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new 4e596819bb6 branch-4.0: [fix](ann index) Fix range search failed 
#56407 (#56515)
4e596819bb6 is described below

commit 4e596819bb693f0fb3f67b5bd18d1a2fd13239e2
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Sep 27 21:43:41 2025 +0800

    branch-4.0: [fix](ann index) Fix range search failed #56407 (#56515)
    
    Cherry-picked from #56407
    
    Co-authored-by: zhiqiang <[email protected]>
---
 be/src/vec/exprs/vectorized_fn_call.cpp            | 25 ++++++----------------
 .../olap/vector_search/ann_range_search_test.cpp   |  2 +-
 2 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/be/src/vec/exprs/vectorized_fn_call.cpp 
b/be/src/vec/exprs/vectorized_fn_call.cpp
index 6ee7a12a251..e43accefab8 100644
--- a/be/src/vec/exprs/vectorized_fn_call.cpp
+++ b/be/src/vec/exprs/vectorized_fn_call.cpp
@@ -336,10 +336,7 @@ bool VectorizedFnCall::equals(const VExpr& other) {
     |----------------
     |               |
     |               |
-    CastToDouble    Float64Literal
-    |
-    |
-    VirtualSlotRef
+    VirtualSlotRef  Float32Literal
     |
     |
     FuncationCall
@@ -380,33 +377,25 @@ void VectorizedFnCall::prepare_ann_range_search(
 
     auto right_col = 
right_literal->get_column_ptr()->convert_to_full_column_if_const();
     auto right_type = right_literal->get_data_type();
-    if (right_type->get_primitive_type() != PrimitiveType::TYPE_DOUBLE) {
+    if (right_type->get_primitive_type() != PrimitiveType::TYPE_FLOAT) {
         suitable_for_ann_index = false;
-        // Right child is not a Float64Literal.
+        // Right child is not a Float32Literal.
         return;
     }
 
-    const ColumnFloat64* cf64_right = assert_cast<const 
ColumnFloat64*>(right_col.get());
-    range_search_runtime.radius = cf64_right->get_data()[0];
+    const ColumnFloat32* cf32_right = assert_cast<const 
ColumnFloat32*>(right_col.get());
+    range_search_runtime.radius = cf32_right->get_data()[0];
 
     // left side
-    auto cast_to_double_expr = 
std::dynamic_pointer_cast<VCastExpr>(left_child);
-    if (cast_to_double_expr == nullptr) {
-        suitable_for_ann_index = false;
-        return;
-    }
-
     std::shared_ptr<VectorizedFnCall> function_call;
-    auto vir_slot_ref =
-            
std::dynamic_pointer_cast<VirtualSlotRef>(cast_to_double_expr->children()[0]);
+    auto vir_slot_ref = std::dynamic_pointer_cast<VirtualSlotRef>(left_child);
     // Return type of L2Distance is always float.
     if (vir_slot_ref != nullptr) {
         DCHECK(vir_slot_ref->get_virtual_column_expr() != nullptr);
         function_call = std::dynamic_pointer_cast<VectorizedFnCall>(
                 vir_slot_ref->get_virtual_column_expr());
     } else {
-        function_call =
-                
std::dynamic_pointer_cast<VectorizedFnCall>(cast_to_double_expr->children()[0]);
+        function_call = 
std::dynamic_pointer_cast<VectorizedFnCall>(left_child);
     }
 
     if (function_call == nullptr) {
diff --git a/be/test/olap/vector_search/ann_range_search_test.cpp 
b/be/test/olap/vector_search/ann_range_search_test.cpp
index 080e3c76f9e..d4839db58c0 100644
--- a/be/test/olap/vector_search/ann_range_search_test.cpp
+++ b/be/test/olap/vector_search/ann_range_search_test.cpp
@@ -49,7 +49,7 @@ namespace doris::vectorized {
 
 // select id, value,l2_distance_approximate(embedding, [1, 2, 3, 4, 5, 6, 7, 
20]) as dist from ann_with_fulltext where l2_distance_approximate(embedding, 
[1, 2, 3, 4, 5, 6, 7, 20]) >= 10;
 const std::string ann_range_search_thrift =
-        
R"xxx({"1":{"lst":["rec",4,{"1":{"i32":2},"2":{"rec":{"1":{"lst":["rec",1,{"1":{"i32":0},"2":{"rec":{"1":{"i32":2},"5":{"i32":0}}}}]},"3":{"i64":-1}}},"3":{"i32":14},"4":{"i32":2},"20":{"i32":-1},"26":{"rec":{"1":{"rec":{"2":{"str":"ge"}}},"2":{"i32":0},"3":{"lst":["rec",2,{"1":{"lst":["rec",1,{"1":{"i32":0},"2":{"rec":{"1":{"i32":8},"5":{"i32":0}}}}]},"3":{"i64":-1}},{"1":{"lst":["rec",1,{"1":{"i32":0},"2":{"rec":{"1":{"i32":8},"5":{"i32":0}}}}]},"3":{"i64":-1}}]},"4":{"rec":{"1
 [...]
+        
R"xxx({"1":{"lst":["rec",3,{"1":{"i32":2},"2":{"rec":{"1":{"lst":["rec",1,{"1":{"i32":0},"2":{"rec":{"1":{"i32":2},"5":{"i32":0}}}}]},"3":{"i64":-1}}},"3":{"i32":14},"4":{"i32":2},"20":{"i32":-1},"26":{"rec":{"1":{"rec":{"2":{"str":"ge"}}},"2":{"i32":0},"3":{"lst":["rec",2,{"1":{"lst":["rec",1,{"1":{"i32":0},"2":{"rec":{"1":{"i32":7},"5":{"i32":0}}}}]},"3":{"i64":-1}},{"1":{"lst":["rec",1,{"1":{"i32":0},"2":{"rec":{"1":{"i32":7},"5":{"i32":0}}}}]},"3":{"i64":-1}}]},"4":{"rec":{"1
 [...]
 
 const std::string thrift_table_desc =
         
R"xxx({"1":{"lst":["rec",7,{"1":{"i32":0},"2":{"i32":0},"3":{"rec":{"1":{"lst":["rec",1,{"1":{"i32":0},"2":{"rec":{"1":{"i32":5},"5":{"i32":0}}}}]},"3":{"i64":-1}}},"4":{"i32":-1},"5":{"i32":-1},"6":{"i32":0},"7":{"i32":-1},"8":{"str":"id"},"9":{"i32":0},"10":{"tf":1},"11":{"i32":0},"12":{"tf":1},"13":{"tf":1},"14":{"tf":0},"17":{"i32":5}},{"1":{"i32":1},"2":{"i32":0},"3":{"rec":{"1":{"lst":["rec",2,{"1":{"i32":1},"4":{"tf":1},"5":{"lst":["tf",1,1]}},{"1":{"i32":0},"2":{"rec":{"1
 [...]


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

Reply via email to