This is an automated email from the ASF dual-hosted git repository. yiguolei pushed a commit to branch branch-2.1 in repository https://gitbox.apache.org/repos/asf/doris.git
commit f67bd4b03bbc5223577d71ba1ffc46b481ac52e1 Author: airborne12 <airborn...@gmail.com> AuthorDate: Sat Jun 1 08:23:01 2024 +0800 [Fix](inverted index) fix fast execute condition for vexpr (#35673) --- be/src/vec/exprs/vectorized_fn_call.cpp | 3 +- be/src/vec/exprs/vexpr.h | 1 + be/src/vec/exprs/vliteral.h | 2 + .../data/inverted_index_p0/test_index_rqg_bug2.out | 19 ++++ .../inverted_index_p0/test_index_rqg_bug2.groovy | 106 +++++++++++++++++++++ 5 files changed, 130 insertions(+), 1 deletion(-) diff --git a/be/src/vec/exprs/vectorized_fn_call.cpp b/be/src/vec/exprs/vectorized_fn_call.cpp index ebdba472fc1..77b6b9a7c9f 100644 --- a/be/src/vec/exprs/vectorized_fn_call.cpp +++ b/be/src/vec/exprs/vectorized_fn_call.cpp @@ -112,7 +112,8 @@ Status VectorizedFnCall::prepare(RuntimeState* state, const RowDescriptor& desc, } VExpr::register_function_context(state, context); _function_name = _fn.name.function_name; - _can_fast_execute = _function->can_fast_execute(); + _can_fast_execute = _function->can_fast_execute() && _children.size() == 2 && + _children[0]->is_slot_ref() && _children[1]->is_literal(); _prepare_finished = true; return Status::OK(); } diff --git a/be/src/vec/exprs/vexpr.h b/be/src/vec/exprs/vexpr.h index e9ca2cc8dc6..c2f4d2ef6fd 100644 --- a/be/src/vec/exprs/vexpr.h +++ b/be/src/vec/exprs/vexpr.h @@ -134,6 +134,7 @@ public: TypeDescriptor type() { return _type; } bool is_slot_ref() const { return _node_type == TExprNodeType::SLOT_REF; } + virtual bool is_literal() const { return false; } TExprNodeType::type node_type() const { return _node_type; } diff --git a/be/src/vec/exprs/vliteral.h b/be/src/vec/exprs/vliteral.h index d443478ada5..c79d795e987 100644 --- a/be/src/vec/exprs/vliteral.h +++ b/be/src/vec/exprs/vliteral.h @@ -55,6 +55,8 @@ public: const ColumnPtr& get_column_ptr() const { return _column_ptr; } + bool is_literal() const override { return true; } + protected: ColumnPtr _column_ptr; std::string _expr_name; diff --git a/regression-test/data/inverted_index_p0/test_index_rqg_bug2.out b/regression-test/data/inverted_index_p0/test_index_rqg_bug2.out new file mode 100644 index 00000000000..484317d51e1 --- /dev/null +++ b/regression-test/data/inverted_index_p0/test_index_rqg_bug2.out @@ -0,0 +1,19 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !select_bug_2 -- +2023-12-10 2024-01-08 +2023-12-15 2023-12-13 +2023-12-15 2023-12-14 +2023-12-17 2025-02-18 +2023-12-18 2023-12-14 +2023-12-18 2024-02-18 +2023-12-20 2023-12-09 +2024-02-18 2023-12-13 +2024-02-18 2025-02-17 +2025-02-18 2024-01-08 +2025-06-18 2023-12-10 +2025-06-18 2023-12-14 +2025-06-18 2023-12-15 +2025-06-18 2026-01-18 +2027-01-09 2023-12-19 +2027-01-09 2024-01-08 + diff --git a/regression-test/suites/inverted_index_p0/test_index_rqg_bug2.groovy b/regression-test/suites/inverted_index_p0/test_index_rqg_bug2.groovy new file mode 100644 index 00000000000..bddbfdc4ab0 --- /dev/null +++ b/regression-test/suites/inverted_index_p0/test_index_rqg_bug2.groovy @@ -0,0 +1,106 @@ +// 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_rqg_bug2", "test_index_rqg_bug2"){ + def table1 = "test_index_rqg_bug2" + + sql "drop table if exists ${table1}" + + sql """ + CREATE TABLE ${table1} ( + col_date_undef_signed_not_null_index_inverted DATE NOT NULL, + col_bigint_undef_signed_not_null_index_inverted BIGINT NOT NULL, + col_bigint_undef_signed_not_null BIGINT NOT NULL, + col_int_undef_signed INT NULL, + col_int_undef_signed_index_inverted INT NULL, + col_int_undef_signed_not_null INT NOT NULL, + col_int_undef_signed_not_null_index_inverted INT NOT NULL, + col_bigint_undef_signed BIGINT NULL, + col_bigint_undef_signed_index_inverted BIGINT NULL, + col_date_undef_signed DATE NULL, + col_date_undef_signed_index_inverted DATE NULL, + col_date_undef_signed_not_null DATE NOT NULL, + col_varchar_10__undef_signed VARCHAR(10) NULL, + col_varchar_10__undef_signed_index_inverted VARCHAR(10) NULL, + col_varchar_10__undef_signed_not_null VARCHAR(10) NOT NULL, + col_varchar_10__undef_signed_not_null_index_inverted VARCHAR(10) NOT NULL, + col_varchar_1024__undef_signed VARCHAR(1024) NULL, + col_varchar_1024__undef_signed_index_inverted VARCHAR(1024) NULL, + col_varchar_1024__undef_signed_not_null VARCHAR(1024) NOT NULL, + col_varchar_1024__undef_signed_not_null_index_inverted VARCHAR(1024) NOT NULL, + col_array_bigint__undef_signed ARRAY<BIGINT> NULL, + col_array_bigint__undef_signed_index_inverted ARRAY<BIGINT> NULL, + col_array_bigint__undef_signed_not_null ARRAY<BIGINT> NOT NULL, + col_array_bigint__undef_signed_not_null_index_inverted ARRAY<BIGINT> NOT NULL, + col_array_varchar_64___undef_signed ARRAY<VARCHAR(64)> NULL, + col_array_varchar_64___undef_signed_index_inverted ARRAY<VARCHAR(64)> NULL, + col_array_varchar_64___undef_signed_not_null ARRAY<VARCHAR(64)> NOT NULL, + col_array_varchar_64___undef_signed_not_null_index_inverted ARRAY<VARCHAR(64)> NOT NULL, + col_array_date__undef_signed ARRAY<DATE> NULL, + col_array_date__undef_signed_index_inverted ARRAY<DATE> NULL, + col_array_date__undef_signed_not_null ARRAY<DATE> NOT NULL, + col_array_date__undef_signed_not_null_index_inverted ARRAY<DATE> NOT NULL, + pk INT, + INDEX col_int_undef_signed_index_inverted_idx (`col_int_undef_signed_index_inverted`) USING INVERTED, + INDEX col_int_undef_signed_not_null_index_inverted_idx (`col_int_undef_signed_not_null_index_inverted`) USING INVERTED, + INDEX col_bigint_undef_signed_index_inverted_idx (`col_bigint_undef_signed_index_inverted`) USING INVERTED, + INDEX col_bigint_undef_signed_not_null_index_inverted_idx (`col_bigint_undef_signed_not_null_index_inverted`) USING INVERTED, + INDEX col_date_undef_signed_index_inverted_idx (`col_date_undef_signed_index_inverted`) USING INVERTED, + INDEX col_date_undef_signed_not_null_index_inverted_idx (`col_date_undef_signed_not_null_index_inverted`) USING INVERTED, + INDEX col_varchar_10__undef_signed_index_inverted_idx (`col_varchar_10__undef_signed_index_inverted`) USING INVERTED, + INDEX col_varchar_10__undef_signed_not_null_index_inverted_idx (`col_varchar_10__undef_signed_not_null_index_inverted`) USING INVERTED, + INDEX col_varchar_1024__undef_signed_index_inverted_idx (`col_varchar_1024__undef_signed_index_inverted`) USING INVERTED, + INDEX col_varchar_1024__undef_signed_not_null_index_inverted_idx (`col_varchar_1024__undef_signed_not_null_index_inverted`) USING INVERTED, + INDEX col_array_bigint__undef_signed_index_inverted_idx (`col_array_bigint__undef_signed_index_inverted`) USING INVERTED, + INDEX col_array_bigint__undef_signed_not_null_index_inverted_idx (`col_array_bigint__undef_signed_not_null_index_inverted`) USING INVERTED, + INDEX col_array_varchar_64___undef_signed_index_inverted_idx (`col_array_varchar_64___undef_signed_index_inverted`) USING INVERTED, + INDEX col_array_varchar_64___undef_signed_not_null_index_inverted_idx (`col_array_varchar_64___undef_signed_not_null_index_inverted`) USING INVERTED, + INDEX col_array_date__undef_signed_index_inverted_idx (`col_array_date__undef_signed_index_inverted`) USING INVERTED, + INDEX col_array_date__undef_signed_not_null_index_inverted_idx (`col_array_date__undef_signed_not_null_index_inverted`) USING INVERTED + ) ENGINE=olap + UNIQUE KEY(col_date_undef_signed_not_null_index_inverted, col_bigint_undef_signed_not_null_index_inverted, col_bigint_undef_signed_not_null) + PARTITION BY RANGE(col_date_undef_signed_not_null_index_inverted) ( + FROM ('2023-01-01') TO ('2035-01-01') INTERVAL 1 YEAR + ) + DISTRIBUTED BY HASH(col_bigint_undef_signed_not_null) + PROPERTIES("enable_unique_key_merge_on_write" = "true", "replication_num" = "1"); + """ + + sql """ + INSERT INTO ${table1}(pk,col_int_undef_signed,col_int_undef_signed_index_inverted,col_int_undef_signed_not_null,col_int_undef_signed_not_null_index_inverted,col_bigint_undef_signed,col_bigint_undef_signed_index_inverted,col_bigint_undef_signed_not_null,col_bigint_undef_signed_not_null_index_inverted,col_date_undef_signed,col_date_undef_signed_index_inverted,col_date_undef_signed_not_null,col_date_undef_signed_not_null_index_inverted,col_varchar_10__undef_signed,col_varchar_10__undef_ [...] + """ + + qt_select_bug_2 """ + SELECT + table1.col_date_undef_signed_not_null_index_inverted, + table1.col_date_undef_signed_index_inverted + FROM + ${table1} AS table1 + WHERE + ( + ( + NOT ( + table1.`col_date_undef_signed_not_null_index_inverted` IN ('2023-12-13') + ) + AND table1.col_date_undef_signed_not_null_index_inverted <> table1.col_date_undef_signed_index_inverted + ) + OR table1.col_date_undef_signed_index_inverted > table1.col_date_undef_signed_not_null_index_inverted + ) + ORDER BY + 1,2; + """ + +} --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org