From afb477c66df216f7020ebb659fe436f9e3fabaad Mon Sep 17 00:00:00 2001 From: airborne12 Date: Tue, 8 Oct 2024 22:12:10 +0800 Subject: [PATCH] [Fix](inverted index) Fix wrong need read data opt when enable_common_expr_pushdown is disabled #40689 (#41562) cherry pick from #40689 --- be/src/olap/rowset/segment_v2/segment_iterator.cpp | 6 ++++++ .../data/inverted_index_p0/test_need_read_data.out | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/be/src/olap/rowset/segment_v2/segment_iterator.cpp b/be/src/olap/rowset/segment_v2/segment_iterator.cpp index bce19bad65..a9b5e792b2 100644 --- a/be/src/olap/rowset/segment_v2/segment_iterator.cpp +++ b/be/src/olap/rowset/segment_v2/segment_iterator.cpp @@ -972,6 +972,12 @@ Status SegmentIterator::_apply_inverted_index() { */ bool SegmentIterator::_check_all_conditions_passed_inverted_index_for_column(ColumnId cid, bool default_return) { + // If common_expr_pushdown is disabled, we cannot guarantee that all conditions are processed by the inverted index. + // Consider a scenario where there is a column predicate and an expression involving the same column in the SQL query, + // such as 'a < 0' and 'abs(a) > 1'. This could potentially lead to errors. + if (_opts.runtime_state && !_opts.runtime_state->query_options().enable_common_expr_pushdown) { + return false; + } auto pred_it = _column_predicate_inverted_index_status.find(cid); if (pred_it != _column_predicate_inverted_index_status.end()) { const auto& pred_map = pred_it->second; diff --git a/regression-test/data/inverted_index_p0/test_need_read_data.out b/regression-test/data/inverted_index_p0/test_need_read_data.out index 5999e7640a..186138a45a 100644 --- a/regression-test/data/inverted_index_p0/test_need_read_data.out +++ b/regression-test/data/inverted_index_p0/test_need_read_data.out @@ -33,4 +33,3 @@ -- !sql_11 -- 1 -