-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](inverted index) fixed in_list condition not indexed on pipelinex #36565
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -994,8 +994,10 @@ void ScanLocalState<Derived>::_normalize_compound_predicate( | |||||
| auto compound_fn_name = expr->fn().name.function_name; | ||||||
| auto children_num = expr->children().size(); | ||||||
| for (auto i = 0; i < children_num; ++i) { | ||||||
| auto child_expr = expr->children()[i].get(); | ||||||
| if (TExprNodeType::BINARY_PRED == child_expr->node_type()) { | ||||||
| auto* child_expr = expr->children()[i].get(); | ||||||
| if (TExprNodeType::BINARY_PRED == child_expr->node_type() || | ||||||
| TExprNodeType::IN_PRED == child_expr->node_type() || | ||||||
| TExprNodeType::MATCH_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, | ||||||
|
|
@@ -1010,30 +1012,16 @@ void ScanLocalState<Derived>::_normalize_compound_predicate( | |||||
| value_range.mark_runtime_filter_predicate( | ||||||
| _is_runtime_filter_predicate); | ||||||
| }}; | ||||||
| static_cast<void>(_normalize_binary_in_compound_predicate( | ||||||
| child_expr, expr_ctx, slot, value_range, pdt)); | ||||||
| }, | ||||||
| active_range); | ||||||
|
|
||||||
| _compound_value_ranges.emplace_back(active_range); | ||||||
| } | ||||||
| } else if (TExprNodeType::MATCH_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) { | ||||||
| Defer mark_runtime_filter_flag {[&]() { | ||||||
| value_range.mark_runtime_filter_predicate( | ||||||
| _is_runtime_filter_predicate); | ||||||
| }}; | ||||||
| static_cast<void>(_normalize_match_in_compound_predicate( | ||||||
| child_expr, expr_ctx, slot, value_range, pdt)); | ||||||
| if (TExprNodeType::BINARY_PRED == child_expr->node_type()) { | ||||||
| static_cast<void>(_normalize_binary_compound_predicate( | ||||||
| child_expr, expr_ctx, slot, value_range, pdt)); | ||||||
| } else if (TExprNodeType::IN_PRED == child_expr->node_type()) { | ||||||
| static_cast<void>(_normalize_in_and_not_in_compound_predicate( | ||||||
| child_expr, expr_ctx, slot, value_range, pdt)); | ||||||
| } else { | ||||||
| static_cast<void>(_normalize_match_compound_predicate( | ||||||
| child_expr, expr_ctx, slot, value_range, pdt)); | ||||||
| } | ||||||
| }, | ||||||
| active_range); | ||||||
|
|
||||||
|
|
@@ -1050,7 +1038,7 @@ void ScanLocalState<Derived>::_normalize_compound_predicate( | |||||
|
|
||||||
| template <typename Derived> | ||||||
| template <PrimitiveType T> | ||||||
| Status ScanLocalState<Derived>::_normalize_binary_in_compound_predicate( | ||||||
| Status ScanLocalState<Derived>::_normalize_binary_compound_predicate( | ||||||
| vectorized::VExpr* expr, vectorized::VExprContext* expr_ctx, SlotDescriptor* slot, | ||||||
| ColumnValueRange<T>& range, PushDownType* pdt) { | ||||||
| DCHECK(expr->children().size() == 2); | ||||||
|
|
@@ -1107,7 +1095,56 @@ Status ScanLocalState<Derived>::_normalize_binary_in_compound_predicate( | |||||
|
|
||||||
| template <typename Derived> | ||||||
| template <PrimitiveType T> | ||||||
| Status ScanLocalState<Derived>::_normalize_match_in_compound_predicate( | ||||||
| Status ScanLocalState<Derived>::_normalize_in_and_not_in_compound_predicate( | ||||||
| vectorized::VExpr* expr, vectorized::VExprContext* expr_ctx, SlotDescriptor* slot, | ||||||
| ColumnValueRange<T>& range, PushDownType* pdt) { | ||||||
| if (TExprNodeType::IN_PRED == expr->node_type()) { | ||||||
| std::string fn_name = expr->op() == TExprOpcode::type::FILTER_IN ? "in" : "not_in"; | ||||||
|
|
||||||
| HybridSetBase::IteratorBase* iter = nullptr; | ||||||
| auto hybrid_set = expr->get_set_func(); | ||||||
|
|
||||||
| if (hybrid_set != nullptr) { | ||||||
| if (hybrid_set->size() <= | ||||||
| _parent->cast<typename Derived::Parent>()._max_pushdown_conditions_per_column) { | ||||||
| iter = hybrid_set->begin(); | ||||||
| } else { | ||||||
| _filter_predicates.in_filters.emplace_back(slot->col_name(), expr->get_set_func()); | ||||||
| *pdt = PushDownType::ACCEPTABLE; | ||||||
| return Status::OK(); | ||||||
| } | ||||||
| } else { | ||||||
| vectorized::VInPredicate* pred = static_cast<vectorized::VInPredicate*>(expr); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
Suggested change
|
||||||
|
|
||||||
| vectorized::InState* state = reinterpret_cast<vectorized::InState*>( | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: use auto when initializing with a cast to avoid duplicating the type name [modernize-use-auto]
Suggested change
|
||||||
| expr_ctx->fn_context(pred->fn_context_index()) | ||||||
| ->get_function_state(FunctionContext::FRAGMENT_LOCAL)); | ||||||
|
|
||||||
| if (!state->use_set) { | ||||||
| return Status::OK(); | ||||||
| } | ||||||
|
|
||||||
| iter = state->hybrid_set->begin(); | ||||||
| } | ||||||
|
|
||||||
| while (iter->has_next()) { | ||||||
| if (nullptr == iter->get_value()) { | ||||||
| iter->next(); | ||||||
| continue; | ||||||
| } | ||||||
| auto* value = const_cast<void*>(iter->get_value()); | ||||||
| RETURN_IF_ERROR(_change_value_range<false>( | ||||||
| range, value, ColumnValueRange<T>::add_compound_value_range, fn_name, 0)); | ||||||
| iter->next(); | ||||||
| } | ||||||
| *pdt = PushDownType::ACCEPTABLE; | ||||||
| } | ||||||
| return Status::OK(); | ||||||
| } | ||||||
|
|
||||||
| template <typename Derived> | ||||||
| template <PrimitiveType T> | ||||||
| Status ScanLocalState<Derived>::_normalize_match_compound_predicate( | ||||||
| vectorized::VExpr* expr, vectorized::VExprContext* expr_ctx, SlotDescriptor* slot, | ||||||
| ColumnValueRange<T>& range, PushDownType* pdt) { | ||||||
| DCHECK(expr->children().size() == 2); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| -- This file is automatically generated. You should know what you did if you want to edit this | ||
| -- !sql -- | ||
| 8 | ||
|
|
||
| -- !sql -- | ||
| 996 | ||
|
|
||
| -- !sql -- | ||
| 210 | ||
|
|
||
| -- !sql -- | ||
| 8 | ||
|
|
||
| -- !sql -- | ||
| 998 | ||
|
|
||
| -- !sql -- | ||
| 208 | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| suite("test_index_inlist_fault_injection", "nonConcurrent") { | ||
| // define a sql table | ||
| def indexTbName = "test_index_inlist_fault_injection" | ||
|
|
||
| sql "DROP TABLE IF EXISTS ${indexTbName}" | ||
| sql """ | ||
| CREATE TABLE ${indexTbName} ( | ||
| `@timestamp` int(11) NULL COMMENT "", | ||
| `clientip` varchar(20) NULL COMMENT "", | ||
| `request` text NULL COMMENT "", | ||
| `status` int(11) NULL COMMENT "", | ||
| `size` int(11) NULL COMMENT "", | ||
| INDEX clientip_idx (`clientip`) USING INVERTED COMMENT '', | ||
| INDEX request_idx (`request`) USING INVERTED PROPERTIES("parser" = "english", "support_phrase" = "true") COMMENT '', | ||
| INDEX status_idx (`status`) USING INVERTED COMMENT '' | ||
| ) ENGINE=OLAP | ||
| DUPLICATE KEY(`@timestamp`) | ||
| COMMENT "OLAP" | ||
| DISTRIBUTED BY RANDOM BUCKETS 1 | ||
| PROPERTIES ( | ||
| "replication_allocation" = "tag.location.default: 1", | ||
| "disable_auto_compaction" = "true" | ||
| ); | ||
| """ | ||
|
|
||
| def load_httplogs_data = {table_name, label, read_flag, format_flag, file_name, ignore_failure=false, | ||
| expected_succ_rows = -1, load_to_single_tablet = 'true' -> | ||
|
|
||
| // load the json data | ||
| streamLoad { | ||
| table "${table_name}" | ||
|
|
||
| // set http request header params | ||
| set 'label', label + "_" + UUID.randomUUID().toString() | ||
| set 'read_json_by_line', read_flag | ||
| set 'format', format_flag | ||
| file file_name // import json file | ||
| time 10000 // limit inflight 10s | ||
| if (expected_succ_rows >= 0) { | ||
| set 'max_filter_ratio', '1' | ||
| } | ||
|
|
||
| // if declared a check callback, the default check condition will ignore. | ||
| // So you must check all condition | ||
| check { result, exception, startTime, endTime -> | ||
| if (ignore_failure && expected_succ_rows < 0) { return } | ||
| if (exception != null) { | ||
| throw exception | ||
| } | ||
| log.info("Stream load result: ${result}".toString()) | ||
| def json = parseJson(result) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| try { | ||
| load_httplogs_data.call(indexTbName, 'test_index_inlist_fault_injection', 'true', 'json', 'documents-1000.json') | ||
|
|
||
| sql "sync" | ||
|
|
||
| try { | ||
| GetDebugPoint().enableDebugPointForAllBEs("segment_iterator._rowid_result_for_index") | ||
|
|
||
| qt_sql """ select /*+ SET_VAR(inverted_index_skip_threshold = 0) */ count() from ${indexTbName} where clientip in ('40.135.0.0', '232.0.0.0', '26.1.0.0'); """ | ||
| qt_sql """ select /*+ SET_VAR(inverted_index_skip_threshold = 0) */ count() from ${indexTbName} where status in (1, 304, 200); """ | ||
| qt_sql """ select /*+ SET_VAR(inverted_index_skip_threshold = 0) */ count() from ${indexTbName} where (request match 'hm' or clientip in ('40.135.0.0', '232.0.0.0', '26.1.0.0')); """ | ||
| qt_sql """ select /*+ SET_VAR(inverted_index_skip_threshold = 0) */ count() from ${indexTbName} where (request match 'hm' and clientip in ('40.135.0.0', '232.0.0.0', '26.1.0.0')); """ | ||
| qt_sql """ select /*+ SET_VAR(inverted_index_skip_threshold = 0) */ count() from ${indexTbName} where (request match 'hm' or status in (1, 304, 200)); """ | ||
| qt_sql """ select /*+ SET_VAR(inverted_index_skip_threshold = 0) */ count() from ${indexTbName} where (request match 'hm' and status in (1, 304, 200)); """ | ||
|
|
||
| } finally { | ||
| GetDebugPoint().disableDebugPointForAllBEs("segment_iterator._rowid_result_for_index") | ||
| } | ||
| } finally { | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function '_normalize_binary_compound_predicate' has cognitive complexity of 54 (threshold 50) [readability-function-cognitive-complexity]
Status ScanLocalState<Derived>::_normalize_binary_compound_predicate( ^Additional context
be/src/pipeline/exec/scan_operator.cpp:1044: +1, including nesting penalty of 0, nesting level increased to 1
be/src/pipeline/exec/scan_operator.cpp:1045: nesting level increased to 2
be/src/pipeline/exec/scan_operator.cpp:1046: nesting level increased to 2
be/src/pipeline/exec/scan_operator.cpp:1047: nesting level increased to 2
be/src/pipeline/exec/scan_operator.cpp:1048: +1
be/src/pipeline/exec/scan_operator.cpp:1056: +2, including nesting penalty of 1, nesting level increased to 2
RETURN_IF_ERROR(_should_push_down_binary_predicate( ^be/src/common/status.h:626: expanded from macro 'RETURN_IF_ERROR'
do { \ ^be/src/pipeline/exec/scan_operator.cpp:1056: +3, including nesting penalty of 2, nesting level increased to 3
RETURN_IF_ERROR(_should_push_down_binary_predicate( ^be/src/common/status.h:628: expanded from macro 'RETURN_IF_ERROR'
if (UNLIKELY(!_status_.ok())) { \ ^be/src/pipeline/exec/scan_operator.cpp:1059: +2, including nesting penalty of 1, nesting level increased to 2
RETURN_IF_ERROR(_should_push_down_binary_predicate( ^be/src/common/status.h:626: expanded from macro 'RETURN_IF_ERROR'
do { \ ^be/src/pipeline/exec/scan_operator.cpp:1059: +3, including nesting penalty of 2, nesting level increased to 3
RETURN_IF_ERROR(_should_push_down_binary_predicate( ^be/src/common/status.h:628: expanded from macro 'RETURN_IF_ERROR'
if (UNLIKELY(!_status_.ok())) { \ ^be/src/pipeline/exec/scan_operator.cpp:1062: +2, including nesting penalty of 1, nesting level increased to 2
RETURN_IF_ERROR(_should_push_down_binary_predicate( ^be/src/common/status.h:626: expanded from macro 'RETURN_IF_ERROR'
do { \ ^be/src/pipeline/exec/scan_operator.cpp:1062: +3, including nesting penalty of 2, nesting level increased to 3
RETURN_IF_ERROR(_should_push_down_binary_predicate( ^be/src/common/status.h:628: expanded from macro 'RETURN_IF_ERROR'
if (UNLIKELY(!_status_.ok())) { \ ^be/src/pipeline/exec/scan_operator.cpp:1065: +2, including nesting penalty of 1, nesting level increased to 2
if (eq_pdt == PushDownType::UNACCEPTABLE && ne_pdt == PushDownType::UNACCEPTABLE && ^be/src/pipeline/exec/scan_operator.cpp:1065: +1
if (eq_pdt == PushDownType::UNACCEPTABLE && ne_pdt == PushDownType::UNACCEPTABLE && ^be/src/pipeline/exec/scan_operator.cpp:1072: +2, including nesting penalty of 1, nesting level increased to 2
if (eq_pdt == PushDownType::ACCEPTABLE || ne_pdt == PushDownType::ACCEPTABLE || ^be/src/pipeline/exec/scan_operator.cpp:1072: +1
if (eq_pdt == PushDownType::ACCEPTABLE || ne_pdt == PushDownType::ACCEPTABLE || ^be/src/pipeline/exec/scan_operator.cpp:1074: +3, including nesting penalty of 2, nesting level increased to 3
be/src/pipeline/exec/scan_operator.cpp:1075: +4, including nesting penalty of 3, nesting level increased to 4
be/src/pipeline/exec/scan_operator.cpp:1075: +1
be/src/pipeline/exec/scan_operator.cpp:1078: +5, including nesting penalty of 4, nesting level increased to 5
be/src/common/status.h:626: expanded from macro 'RETURN_IF_ERROR'
do { \ ^be/src/pipeline/exec/scan_operator.cpp:1078: +6, including nesting penalty of 5, nesting level increased to 6
be/src/common/status.h:628: expanded from macro 'RETURN_IF_ERROR'
if (UNLIKELY(!_status_.ok())) { \ ^be/src/pipeline/exec/scan_operator.cpp:1082: +1, nesting level increased to 4
} else { ^be/src/pipeline/exec/scan_operator.cpp:1083: +5, including nesting penalty of 4, nesting level increased to 5
be/src/common/status.h:626: expanded from macro 'RETURN_IF_ERROR'
do { \ ^be/src/pipeline/exec/scan_operator.cpp:1083: +6, including nesting penalty of 5, nesting level increased to 6
be/src/common/status.h:628: expanded from macro 'RETURN_IF_ERROR'
if (UNLIKELY(!_status_.ok())) { \ ^