airborne12 commented on code in PR #56718:
URL: https://github.com/apache/doris/pull/56718#discussion_r2434865906
##########
be/src/vec/exprs/vsearch.cpp:
##########
@@ -48,39 +48,63 @@ Status collect_search_inputs(const VSearchExpr& expr,
VExprContext* context,
auto index_context = context->get_inverted_index_context();
if (index_context == nullptr) {
- return Status::OK();
+ LOG(WARNING) << "collect_search_inputs: No inverted index context
available";
+ return Status::InternalError("No inverted index context available");
}
+ // Get field bindings for variant subcolumn support
+ const auto& search_param = expr.get_search_param();
+ const auto& field_bindings = search_param.field_bindings;
+
+ int child_index = 0; // Index for iterating through children
for (const auto& child : expr.children()) {
if (child->is_slot_ref()) {
auto* column_slot_ref = assert_cast<VSlotRef*>(child.get());
int column_id = column_slot_ref->column_id();
auto* iterator =
index_context->get_inverted_index_iterator_by_column_id(column_id);
- if (iterator == nullptr) {
- continue;
+
+ // Determine the field_name from field_bindings (for variant
subcolumns)
+ // field_bindings and children should have the same order
+ std::string field_name;
+ if (child_index < field_bindings.size()) {
+ // Use field_name from binding (may include "parent.subcolumn"
for variant)
+ field_name = field_bindings[child_index].field_name;
+ } else {
+ // Fallback to column_name if binding not found
+ field_name = column_slot_ref->column_name();
}
- const auto* storage_name_type =
-
index_context->get_storage_name_and_type_by_column_id(column_id);
- if (storage_name_type == nullptr) {
- auto err_msg = fmt::format(
- "storage_name_type cannot be found for column {} while
in {} evaluate",
- column_id, expr.expr_name());
- LOG(ERROR) << err_msg;
- return Status::InternalError(err_msg);
+ // Only collect fields that have iterators (materialized columns
with indexes)
+ if (iterator != nullptr) {
+ const auto* storage_name_type =
+
index_context->get_storage_name_and_type_by_column_id(column_id);
+ if (storage_name_type == nullptr) {
+ return Status::InternalError("storage_name_type not found
for column {} in {}",
+ column_id, expr.expr_name());
+ }
+
+ bundle->iterators.emplace(field_name, iterator);
+ bundle->field_types.emplace(field_name, *storage_name_type);
+ bundle->column_ids.emplace_back(column_id);
}
- auto column_name = column_slot_ref->column_name();
- bundle->iterators.emplace(column_name, iterator);
- bundle->field_types.emplace(column_name, *storage_name_type);
- bundle->column_ids.emplace_back(column_id);
+ child_index++;
} else if (child->is_literal()) {
auto* literal = assert_cast<VLiteral*>(child.get());
bundle->literal_args.emplace_back(literal->get_column_ptr(),
literal->get_data_type(),
literal->expr_name());
} else {
- LOG(WARNING) << "VSearchExpr: Unsupported child node type
encountered";
- return Status::InvalidArgument("search expression child type
unsupported");
+ // Check if this is ElementAt expression (for variant subcolumn
access)
+ if (child->expr_name() == "element_at" && child_index <
field_bindings.size() &&
Review Comment:
Yes, but is there any special cases?
--
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]