HappenLee commented on code in PR #55458:
URL: https://github.com/apache/doris/pull/55458#discussion_r2335549791
##########
be/src/vec/exprs/vectorized_fn_call.cpp:
##########
@@ -425,43 +425,80 @@ void VectorizedFnCall::prepare_ann_range_search(
range_search_runtime.metric_type =
segment_v2::string_to_metric(metric_name);
}
- UInt16 idx_of_slot_ref = 0;
- UInt16 idx_of_array_literal = 0;
+ // Identify the slot ref child and the constant query array child
(ArrayLiteral or CAST to array)
+ Int32 idx_of_slot_ref = -1;
+ Int32 idx_of_array_expr = -1;
for (UInt16 i = 0; i < function_call->get_num_children(); ++i) {
auto child = function_call->get_child(i);
- if (std::dynamic_pointer_cast<VSlotRef>(child) != nullptr) {
+ if (idx_of_slot_ref == -1 &&
std::dynamic_pointer_cast<VSlotRef>(child) != nullptr) {
idx_of_slot_ref = i;
- } else if (std::dynamic_pointer_cast<VArrayLiteral>(child) != nullptr)
{
- idx_of_array_literal = i;
+ continue;
+ }
+ // Accept either ArrayLiteral or Cast-to-array constant
+ if (idx_of_array_expr == -1 &&
+ (std::dynamic_pointer_cast<VArrayLiteral>(child) != nullptr ||
+ std::dynamic_pointer_cast<VCastExpr>(child) != nullptr)) {
+ idx_of_array_expr = i;
}
}
- std::shared_ptr<VSlotRef> slot_ref =
-
std::dynamic_pointer_cast<VSlotRef>(function_call->get_child(idx_of_slot_ref));
- std::shared_ptr<VArrayLiteral> array_literal =
std::dynamic_pointer_cast<VArrayLiteral>(
- function_call->get_child(idx_of_array_literal));
-
- if (slot_ref == nullptr || array_literal == nullptr) {
+ if (idx_of_slot_ref == -1 || idx_of_array_expr == -1) {
suitable_for_ann_index = false;
- // slot ref or array literal is null.
+ // slot ref or array literal/cast is missing.
return;
}
+ auto slot_ref = std::dynamic_pointer_cast<VSlotRef>(
+ function_call->get_child(static_cast<UInt16>(idx_of_slot_ref)));
Review Comment:
why direct use UINT16?
--
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]