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


##########
be/src/olap/rowset/beta_rowset_reader.cpp:
##########
@@ -122,6 +123,14 @@ Status 
BetaRowsetReader::get_segment_iterators(RowsetReaderContext* read_context
                     single_column_block_predicate);
         }
     }
+    
+    if (read_context->all_compound_predicates != nullptr) {
+        read_options.all_compound_column_predicates.insert(

Review Comment:
   warning: use of undeclared identifier 'read_options'; did you mean 
'_read_options'? [clang-diagnostic-error]
   
   ```suggestion
           _read_options.all_compound_column_predicates.insert(
   ```
   **be/src/olap/rowset/beta_rowset_reader.h:98:** '_read_options' declared here
   ```cpp
       StorageReadOptions _read_options;
                          ^
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -374,6 +394,176 @@
     return Status::OK();
 }
 
+bool SegmentIterator::_is_literal_node(const TExprNodeType::type& node_type) {
+    switch (node_type) {
+    case TExprNodeType::BOOL_LITERAL:
+    case TExprNodeType::INT_LITERAL:
+    case TExprNodeType::LARGE_INT_LITERAL:
+    case TExprNodeType::FLOAT_LITERAL:
+    case TExprNodeType::DECIMAL_LITERAL:
+    case TExprNodeType::STRING_LITERAL:
+    case TExprNodeType::DATE_LITERAL:
+        return true;
+    default:
+        return false;
+    }
+}
+
+Status SegmentIterator::_execute_all_compound_predicates(vectorized::VExpr* 
expr) {
+    if (expr == nullptr) {
+        return Status::OK();
+    }
+
+    auto children = expr->children();
+    for (int i = 0; i < children.size(); ++i) {
+        RETURN_IF_ERROR(_execute_all_compound_predicates(children[i]));
+    }
+
+    auto node_type = expr->node_type();
+    if (node_type == TExprNodeType::SLOT_REF) {
+        _column_predicate_info->column_name = expr->expr_name();
+    } else if (_is_literal_node(node_type)) {
+        auto v_literal_expr =  
dynamic_cast<doris::vectorized::VLiteral*>(expr);
+        _column_predicate_info->query_value = v_literal_expr->value();
+    } else if (node_type == TExprNodeType::BINARY_PRED) {
+        _column_predicate_info->query_op = expr->fn().name.function_name;
+        // get child condition result in compound condtions
+        auto column_sign = _gen_predicate_sign(_column_predicate_info.get());
+        _column_predicate_info.reset(new ColumnPredicateInfo());
+        if (_rowid_result_for_index.count(column_sign) > 0 
+                && _rowid_result_for_index[column_sign].first) {
+            auto apply_reuslt = _rowid_result_for_index[column_sign].second;
+            _compound_predicate_execute_result.push_back(apply_reuslt);
+        }
+    } else if (node_type == TExprNodeType::COMPOUND_PRED) {
+        auto function_name = expr->fn().name.function_name;
+        // execute logic function
+        RETURN_IF_ERROR(_execute_compound_fn(function_name));
+    }
+
+    return Status::OK();
+}
+
+Status SegmentIterator::_execute_compound_fn(const std::string& function_name) 
{
+    auto and_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 2) {
+            return Status::InternalError("execute and logic compute error.");
+        }
+        _compound_predicate_execute_result.at(size - 2) &= 
_compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.pop_back();
+    };
+
+    auto or_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 2) {
+            return Status::InternalError("execute or logic compute error.");
+        }
+        _compound_predicate_execute_result.at(size - 2) |= 
_compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.pop_back();
+    };
+
+    auto not_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 1) {
+            return Status::InternalError("execute not logic compute error.");
+        }
+        roaring::Roaring tmp = _row_bitmap;
+        tmp -= _compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.at(size - 1) = tmp;
+    };

Review Comment:
   warning: non-void lambda does not return a value in all control paths 
[clang-diagnostic-return-type]
   ```cpp
       };
       ^
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.h:
##########
@@ -47,6 +48,13 @@ class BitmapIndexIterator;
 class BitmapIndexReader;
 class ColumnIterator;
 
+struct ColumnPredicateInfo {
+    ColumnPredicateInfo() {};

Review Comment:
   warning: use '= default' to define a trivial default constructor 
[modernize-use-equals-default]
   
   ```suggestion
       ColumnPredicateInfo() = default;;
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -374,6 +394,176 @@
     return Status::OK();
 }
 
+bool SegmentIterator::_is_literal_node(const TExprNodeType::type& node_type) {
+    switch (node_type) {
+    case TExprNodeType::BOOL_LITERAL:
+    case TExprNodeType::INT_LITERAL:
+    case TExprNodeType::LARGE_INT_LITERAL:
+    case TExprNodeType::FLOAT_LITERAL:
+    case TExprNodeType::DECIMAL_LITERAL:
+    case TExprNodeType::STRING_LITERAL:
+    case TExprNodeType::DATE_LITERAL:
+        return true;
+    default:
+        return false;
+    }
+}
+
+Status SegmentIterator::_execute_all_compound_predicates(vectorized::VExpr* 
expr) {
+    if (expr == nullptr) {
+        return Status::OK();
+    }
+
+    auto children = expr->children();
+    for (int i = 0; i < children.size(); ++i) {
+        RETURN_IF_ERROR(_execute_all_compound_predicates(children[i]));
+    }
+
+    auto node_type = expr->node_type();
+    if (node_type == TExprNodeType::SLOT_REF) {
+        _column_predicate_info->column_name = expr->expr_name();
+    } else if (_is_literal_node(node_type)) {
+        auto v_literal_expr =  
dynamic_cast<doris::vectorized::VLiteral*>(expr);
+        _column_predicate_info->query_value = v_literal_expr->value();
+    } else if (node_type == TExprNodeType::BINARY_PRED) {
+        _column_predicate_info->query_op = expr->fn().name.function_name;
+        // get child condition result in compound condtions
+        auto column_sign = _gen_predicate_sign(_column_predicate_info.get());
+        _column_predicate_info.reset(new ColumnPredicateInfo());
+        if (_rowid_result_for_index.count(column_sign) > 0 
+                && _rowid_result_for_index[column_sign].first) {
+            auto apply_reuslt = _rowid_result_for_index[column_sign].second;
+            _compound_predicate_execute_result.push_back(apply_reuslt);
+        }
+    } else if (node_type == TExprNodeType::COMPOUND_PRED) {
+        auto function_name = expr->fn().name.function_name;
+        // execute logic function
+        RETURN_IF_ERROR(_execute_compound_fn(function_name));
+    }
+
+    return Status::OK();
+}
+
+Status SegmentIterator::_execute_compound_fn(const std::string& function_name) 
{
+    auto and_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 2) {
+            return Status::InternalError("execute and logic compute error.");
+        }
+        _compound_predicate_execute_result.at(size - 2) &= 
_compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.pop_back();
+    };
+
+    auto or_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 2) {
+            return Status::InternalError("execute or logic compute error.");
+        }
+        _compound_predicate_execute_result.at(size - 2) |= 
_compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.pop_back();
+    };

Review Comment:
   warning: non-void lambda does not return a value in all control paths 
[clang-diagnostic-return-type]
   ```cpp
       };
       ^
   ```
   



##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -868,6 +878,186 @@
     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 =

Review Comment:
   warning: no viable conversion from 'doris::Status' to 
'doris::vectorized::VScanNode::PushDownType' [clang-diagnostic-error]
   ```cpp
           PushDownType ne_pdt =
                        ^
   ```
   **be/src/common/status.h:494:** candidate function
   ```cpp
       operator bool() const { return this->ok(); }
       ^
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -374,6 +394,176 @@ Status SegmentIterator::_apply_bitmap_index() {
     return Status::OK();
 }
 
+bool SegmentIterator::_is_literal_node(const TExprNodeType::type& node_type) {
+    switch (node_type) {
+    case TExprNodeType::BOOL_LITERAL:
+    case TExprNodeType::INT_LITERAL:
+    case TExprNodeType::LARGE_INT_LITERAL:
+    case TExprNodeType::FLOAT_LITERAL:
+    case TExprNodeType::DECIMAL_LITERAL:
+    case TExprNodeType::STRING_LITERAL:
+    case TExprNodeType::DATE_LITERAL:
+        return true;
+    default:
+        return false;
+    }
+}
+
+Status SegmentIterator::_execute_all_compound_predicates(vectorized::VExpr* 
expr) {
+    if (expr == nullptr) {
+        return Status::OK();
+    }
+
+    auto children = expr->children();
+    for (int i = 0; i < children.size(); ++i) {
+        RETURN_IF_ERROR(_execute_all_compound_predicates(children[i]));
+    }
+
+    auto node_type = expr->node_type();
+    if (node_type == TExprNodeType::SLOT_REF) {
+        _column_predicate_info->column_name = expr->expr_name();
+    } else if (_is_literal_node(node_type)) {
+        auto v_literal_expr =  
dynamic_cast<doris::vectorized::VLiteral*>(expr);
+        _column_predicate_info->query_value = v_literal_expr->value();
+    } else if (node_type == TExprNodeType::BINARY_PRED) {
+        _column_predicate_info->query_op = expr->fn().name.function_name;
+        // get child condition result in compound condtions
+        auto column_sign = _gen_predicate_sign(_column_predicate_info.get());
+        _column_predicate_info.reset(new ColumnPredicateInfo());
+        if (_rowid_result_for_index.count(column_sign) > 0 
+                && _rowid_result_for_index[column_sign].first) {
+            auto apply_reuslt = _rowid_result_for_index[column_sign].second;
+            _compound_predicate_execute_result.push_back(apply_reuslt);
+        }
+    } else if (node_type == TExprNodeType::COMPOUND_PRED) {
+        auto function_name = expr->fn().name.function_name;
+        // execute logic function
+        RETURN_IF_ERROR(_execute_compound_fn(function_name));
+    }
+
+    return Status::OK();
+}
+
+Status SegmentIterator::_execute_compound_fn(const std::string& function_name) 
{
+    auto and_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 2) {
+            return Status::InternalError("execute and logic compute error.");
+        }
+        _compound_predicate_execute_result.at(size - 2) &= 
_compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.pop_back();
+    };

Review Comment:
   warning: non-void lambda does not return a value in all control paths 
[clang-diagnostic-return-type]
   ```cpp
       };
       ^
   ```
   



##########
be/src/vec/exec/scan/new_olap_scan_node.cpp:
##########
@@ -228,10 +228,33 @@
             std::visit([&](auto&& range) { range.to_olap_filter(filters); }, 
iter.second);
 
             for (const auto& filter : filters) {
-                _olap_filters.push_back(filter);
+                _olap_filters.push_back(std::move(filter));
             }
         }
 
+        for (auto i = 0; i < _compound_value_ranges.size(); ++i) {
+            std::vector<TCondition> conditions;
+            for (auto& iter : _compound_value_ranges[i]) {
+                std::vector<TCondition> filters;
+                std::visit([&](auto&& range) { 
+                    if (range.is_boundary_value_range()) {
+                        range.to_boundary_condition(filters); 
+                    } else {
+                        range.to_olap_filter(filters);
+                    }
+
+                }, iter);
+
+                for (const auto& filter : filters) {
+                    conditions.push_back(std::move(filter));

Review Comment:
   warning: std::move of the const variable 'filter' has no effect; remove 
std::move() or make the variable non-const [performance-move-const-arg]
   
   ```suggestion
                       conditions.push_back(filter);
   ```
   



##########
be/src/olap/rowset/beta_rowset_reader.cpp:
##########
@@ -122,6 +123,14 @@
                     single_column_block_predicate);
         }
     }
+    
+    if (read_context->all_compound_predicates != nullptr) {
+        read_options.all_compound_column_predicates.insert(
+                read_options.all_compound_column_predicates.end(),

Review Comment:
   warning: use of undeclared identifier 'read_options'; did you mean 
'_read_options'? [clang-diagnostic-error]
   
   ```suggestion
                   _read_options.all_compound_column_predicates.end(),
   ```
   **be/src/olap/rowset/beta_rowset_reader.h:98:** '_read_options' declared here
   ```cpp
       StorageReadOptions _read_options;
                          ^
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.h:
##########
@@ -167,6 +183,17 @@
 
     void _update_max_row(const vectorized::Block* block);
 
+    bool _check_apply_by_bitmap_index(ColumnPredicate* pred);
+
+    std::string _gen_predicate_sign(ColumnPredicate* predicate);
+    std::string _gen_predicate_sign(ColumnPredicateInfo* predicate_info);
+
+    void _build_index_return_column(vectorized::Block* block, const 
std::string& index_result_column_sign,
+                                    const roaring::Roaring& index_result);
+
+    void _output_index_return_column(vectorized::Block* block);
+
+private:

Review Comment:
   warning: redundant access specifier has the same accessibility as the 
previous access specifier [readability-redundant-access-specifiers]
   
   ```suggestion
   
   ```
   **be/src/olap/rowset/segment_v2/segment_iterator.h:89:** previously declared 
here
   ```cpp
   private:
   ^
   ```
   



##########
be/src/vec/exec/scan/new_olap_scan_node.cpp:
##########
@@ -228,10 +228,33 @@ Status NewOlapScanNode::_build_key_ranges_and_filters() {
             std::visit([&](auto&& range) { range.to_olap_filter(filters); }, 
iter.second);
 
             for (const auto& filter : filters) {
-                _olap_filters.push_back(filter);
+                _olap_filters.push_back(std::move(filter));

Review Comment:
   warning: std::move of the const variable 'filter' has no effect; remove 
std::move() or make the variable non-const [performance-move-const-arg]
   
   ```suggestion
                   _olap_filters.push_back(filter);
   ```
   



##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -462,6 +463,15 @@ Status VScanNode::_normalize_predicate(VExpr* 
conjunct_expr_root, VExpr** output
                         },
                         *range);
             }
+
+            if (pdt == PushDownType::UNACCEPTABLE && is_compound_predicate) {
+                std::vector<ColumnValueRangeType> column_value_rangs;
+                _normalize_compound_predicate(cur_expr, 
*(_vconjunct_ctx_ptr.get()), 

Review Comment:
   warning: redundant get() call on smart pointer 
[readability-redundant-smartptr-get]
   
   ```suggestion
                   _normalize_compound_predicate(cur_expr, 
*(_vconjunct_ctx_ptr), 
   ```
   



##########
be/src/olap/rowset/segment_v2/segment_iterator.cpp:
##########
@@ -374,6 +394,176 @@
     return Status::OK();
 }
 
+bool SegmentIterator::_is_literal_node(const TExprNodeType::type& node_type) {
+    switch (node_type) {
+    case TExprNodeType::BOOL_LITERAL:
+    case TExprNodeType::INT_LITERAL:
+    case TExprNodeType::LARGE_INT_LITERAL:
+    case TExprNodeType::FLOAT_LITERAL:
+    case TExprNodeType::DECIMAL_LITERAL:
+    case TExprNodeType::STRING_LITERAL:
+    case TExprNodeType::DATE_LITERAL:
+        return true;
+    default:
+        return false;
+    }
+}
+
+Status SegmentIterator::_execute_all_compound_predicates(vectorized::VExpr* 
expr) {
+    if (expr == nullptr) {
+        return Status::OK();
+    }
+
+    auto children = expr->children();
+    for (int i = 0; i < children.size(); ++i) {
+        RETURN_IF_ERROR(_execute_all_compound_predicates(children[i]));
+    }
+
+    auto node_type = expr->node_type();
+    if (node_type == TExprNodeType::SLOT_REF) {
+        _column_predicate_info->column_name = expr->expr_name();
+    } else if (_is_literal_node(node_type)) {
+        auto v_literal_expr =  
dynamic_cast<doris::vectorized::VLiteral*>(expr);
+        _column_predicate_info->query_value = v_literal_expr->value();
+    } else if (node_type == TExprNodeType::BINARY_PRED) {
+        _column_predicate_info->query_op = expr->fn().name.function_name;
+        // get child condition result in compound condtions
+        auto column_sign = _gen_predicate_sign(_column_predicate_info.get());
+        _column_predicate_info.reset(new ColumnPredicateInfo());
+        if (_rowid_result_for_index.count(column_sign) > 0 
+                && _rowid_result_for_index[column_sign].first) {
+            auto apply_reuslt = _rowid_result_for_index[column_sign].second;
+            _compound_predicate_execute_result.push_back(apply_reuslt);
+        }
+    } else if (node_type == TExprNodeType::COMPOUND_PRED) {
+        auto function_name = expr->fn().name.function_name;
+        // execute logic function
+        RETURN_IF_ERROR(_execute_compound_fn(function_name));
+    }
+
+    return Status::OK();
+}
+
+Status SegmentIterator::_execute_compound_fn(const std::string& function_name) 
{
+    auto and_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 2) {
+            return Status::InternalError("execute and logic compute error.");
+        }
+        _compound_predicate_execute_result.at(size - 2) &= 
_compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.pop_back();
+    };
+
+    auto or_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 2) {
+            return Status::InternalError("execute or logic compute error.");
+        }
+        _compound_predicate_execute_result.at(size - 2) |= 
_compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.pop_back();
+    };
+
+    auto not_execute_result = [&]() {
+        auto size = _compound_predicate_execute_result.size();
+        if (size < 1) {
+            return Status::InternalError("execute not logic compute error.");
+        }
+        roaring::Roaring tmp = _row_bitmap;
+        tmp -= _compound_predicate_execute_result.at(size - 1);
+        _compound_predicate_execute_result.at(size - 1) = tmp;
+    };
+
+    if (function_name == "and") {
+        and_execute_result();
+    } else if (function_name == "or") {
+        or_execute_result();
+    } else if (function_name == "not") {
+        not_execute_result();
+    }
+    return Status::OK();
+}
+
+bool SegmentIterator::_is_index_for_compound_predicate() {
+    for (auto pred : _all_compound_col_predicates) {
+        if (!_check_apply_by_bitmap_index(pred)) {
+            return false;
+        }
+    }
+    return true;
+}
+
+bool SegmentIterator::_check_apply_by_bitmap_index(ColumnPredicate* pred) {
+    int32_t unique_id = _schema.unique_id(pred->column_id());
+    if (_bitmap_index_iterators.count(unique_id) < 1 ||
+        _bitmap_index_iterators[unique_id] == nullptr) {
+        // no bitmap index for this column
+        return false;
+    }
+    return true;
+}
+
+Status SegmentIterator::_apply_bitmap_index_in_compound(ColumnPredicate* pred, 
roaring::Roaring* output_result) {
+    int32_t unique_id = _schema.unique_id(pred->column_id());
+    RETURN_IF_ERROR(pred->evaluate(_bitmap_index_iterators[unique_id], 
_segment->num_rows(),
+                                       output_result));
+    return Status::OK();
+}
+
+Status SegmentIterator::_apply_index_in_compound() {
+    for (auto pred : _all_compound_col_predicates) {
+        auto pred_type = pred->type();
+        bool is_support_in_compound = 
+                pred_type == PredicateType::EQ || pred_type == 
PredicateType::NE ||
+                pred_type == PredicateType::LT || pred_type == 
PredicateType::LE ||
+                pred_type == PredicateType::GT || pred_type == 
PredicateType::GE ||
+                pred_type == PredicateType::MATCH;

Review Comment:
   warning: no member named 'MATCH' in 'doris::PredicateType' 
[clang-diagnostic-error]
   ```cpp
                   pred_type == PredicateType::MATCH;
                                               ^
   ```
   



##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -868,6 +878,186 @@
     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 =

Review Comment:
   warning: no viable conversion from 'doris::Status' to 
'doris::vectorized::VScanNode::PushDownType' [clang-diagnostic-error]
   ```cpp
           PushDownType eq_pdt =
                        ^
   ```
   **be/src/common/status.h:494:** candidate function
   ```cpp
       operator bool() const { return this->ok(); }
       ^
   ```
   



##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -868,6 +878,186 @@
     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);

Review Comment:
   warning: too few arguments to function call, expected 6, have 5 
[clang-diagnostic-error]
   ```cpp
                                                      expr_ctx, &value, 
&slot_ref_child, ne_checker);
                                                                                
                   ^
   ```
   **be/src/vec/exec/scan/vscan_node.h:136:** 
'_should_push_down_binary_predicate' declared here
   ```cpp
       virtual Status _should_push_down_binary_predicate(
                      ^
   ```
   



##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -868,6 +878,186 @@
     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);

Review Comment:
   warning: too few arguments to function call, expected 6, have 5 
[clang-diagnostic-error]
   ```cpp
                                                      expr_ctx, &value, 
&slot_ref_child, eq_checker);
                                                                                
                   ^
   ```
   **be/src/vec/exec/scan/vscan_node.cpp:900:** in instantiation of function 
template specialization 
'doris::vectorized::VScanNode::_normalize_binary_in_compound_predicate<doris::TYPE_TINYINT>'
 requested here
   ```cpp
                              _normalize_binary_in_compound_predicate(
                              ^
   ```
   **be/src/vec/exec/scan/vscan_node.h:136:** 
'_should_push_down_binary_predicate' declared here
   ```cpp
       virtual Status _should_push_down_binary_predicate(
                      ^
   ```
   



##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -868,6 +878,186 @@
     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), 

Review Comment:
   warning: no viable conversion from 'doris::Status' to 
'doris::vectorized::VScanNode::PushDownType' [clang-diagnostic-error]
   ```cpp
           PushDownType noneq_pdt = 
_should_push_down_binary_predicate(reinterpret_cast<VectorizedFnCall*>(expr), 
                        ^
   ```
   **be/src/common/status.h:494:** candidate function
   ```cpp
       operator bool() const { return this->ok(); }
       ^
   ```
   



##########
be/src/vec/exec/scan/vscan_node.cpp:
##########
@@ -868,6 +878,186 @@
     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);

Review Comment:
   warning: too few arguments to function call, expected 6, have 5 
[clang-diagnostic-error]
   ```cpp
                                                       expr_ctx, &value, 
&slot_ref_child, noneq_checker);
                                                                                
                       ^
   ```
   **be/src/vec/exec/scan/vscan_node.h:136:** 
'_should_push_down_binary_predicate' declared here
   ```cpp
       virtual Status _should_push_down_binary_predicate(
                      ^
   ```
   



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


Reply via email to