Tanya-W commented on code in PR #13035: URL: https://github.com/apache/doris/pull/13035#discussion_r1057229448
########## be/src/vec/exec/scan/vscan_node.cpp: ########## @@ -822,6 +832,186 @@ Status VScanNode::_normalize_noneq_binary_predicate(VExpr* expr, VExprContext* e return Status::OK(); } +Status VScanNode::_normalize_compound_predicate(vectorized::VExpr* expr, + VExprContext* expr_ctx, + PushDownType* pdt, + std::vector<ColumnValueRangeType>* column_value_rangs, + const std::function<bool(const std::vector<VExpr*>&, const VSlotRef**, VExpr**)>& in_predicate_checker, + const std::function<bool(const std::vector<VExpr*>&, const VSlotRef**, VExpr**)>& eq_predicate_checker) { + if (TExprNodeType::COMPOUND_PRED == expr->node_type()) { + DCHECK(expr->children().size() == 2); + auto compound_fn_name = expr->fn().name.function_name; + auto children_num = expr->children().size(); + for (auto i = 0; i < children_num; ++i) { + VExpr* child_expr = expr->children()[i]; + if (TExprNodeType::BINARY_PRED == child_expr->node_type()) { + SlotDescriptor* slot = nullptr; + ColumnValueRangeType* range_on_slot = nullptr; + if (_is_predicate_acting_on_slot(child_expr, in_predicate_checker, &slot, &range_on_slot) || + _is_predicate_acting_on_slot(child_expr, eq_predicate_checker, &slot, &range_on_slot)) { + ColumnValueRangeType active_range = *range_on_slot; // copy, in order not to affect the range in the _colname_to_value_range + std::visit( + [&](auto& value_range) { + _normalize_binary_in_compound_predicate( + child_expr, expr_ctx, slot, value_range, pdt, + _get_compound_type_by_fn_name(compound_fn_name)); + }, + active_range); + + column_value_rangs->emplace_back(active_range); + } + } else if (TExprNodeType::COMPOUND_PRED == child_expr->node_type()) { + _normalize_compound_predicate( + child_expr, expr_ctx, + pdt, column_value_rangs, + in_predicate_checker, eq_predicate_checker); + } + } + } + + return Status::OK(); +} + +template <PrimitiveType T> +Status VScanNode::_normalize_binary_in_compound_predicate( + vectorized::VExpr* expr, VExprContext* expr_ctx, + SlotDescriptor* slot, ColumnValueRange<T>& range, + PushDownType* pdt, const TCompoundType::type& compound_type) { + DCHECK(expr->children().size() == 2); + if (TExprNodeType::BINARY_PRED == expr->node_type()) { + auto eq_checker = [](const std::string& fn_name) { return fn_name == "eq"; }; + auto ne_checker = [](const std::string& fn_name) { return fn_name == "ne"; }; + auto noneq_checker = [](const std::string& fn_name) { + return fn_name != "ne" && fn_name != "eq"; + }; + + StringRef value; + int slot_ref_child = -1; + PushDownType eq_pdt = + _should_push_down_binary_predicate(reinterpret_cast<VectorizedFnCall*>(expr), + expr_ctx, &value, &slot_ref_child, eq_checker); + PushDownType ne_pdt = + _should_push_down_binary_predicate(reinterpret_cast<VectorizedFnCall*>(expr), + expr_ctx, &value, &slot_ref_child, ne_checker); + PushDownType noneq_pdt = _should_push_down_binary_predicate(reinterpret_cast<VectorizedFnCall*>(expr), + expr_ctx, &value, &slot_ref_child, noneq_checker); + + if (eq_pdt == PushDownType::UNACCEPTABLE + && ne_pdt == PushDownType::UNACCEPTABLE + && noneq_pdt == PushDownType::UNACCEPTABLE) { + return Status::OK(); + } + DCHECK(slot_ref_child >= 0); + + if (eq_pdt == PushDownType::ACCEPTABLE) { + auto temp_range = ColumnValueRange<T>::create_empty_column_value_range(slot->type().precision, + slot->type().scale); + auto fn_name = std::string(""); Review Comment: _change_value_range with fixed value not use fn_name, so set empty is ok -- 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: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org