This is an automated email from the ASF dual-hosted git repository.
airborne pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 185fa9ad960 [Fix](inverted index) fix fast execute for not_in expr
#37745 (#38650)
185fa9ad960 is described below
commit 185fa9ad960f08fa466183d49f02a96296d1f63d
Author: airborne12 <[email protected]>
AuthorDate: Thu Aug 1 12:17:33 2024 +0800
[Fix](inverted index) fix fast execute for not_in expr #37745 (#38650)
cherry pick from #37745
---
be/src/vec/exprs/vexpr.cpp | 3 +-
be/src/vec/functions/function.h | 2 +-
.../data/inverted_index_p0/test_index_rqg_bug3.out | 43 ++++++++++++
.../inverted_index_p0/test_index_rqg_bug3.groovy | 81 ++++++++++++++++++++++
4 files changed, 127 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/exprs/vexpr.cpp b/be/src/vec/exprs/vexpr.cpp
index ea46b3c7636..f1a9441890c 100644
--- a/be/src/vec/exprs/vexpr.cpp
+++ b/be/src/vec/exprs/vexpr.cpp
@@ -476,7 +476,8 @@ std::string VExpr::gen_predicate_result_sign(Block& block,
const ColumnNumbers&
std::string column_name = block.get_by_position(arguments[0]).name;
pred_result_sign +=
BeConsts::BLOCK_TEMP_COLUMN_PREFIX + column_name + "_" +
function_name + "_";
- if (function_name == "in") {
+ if (function_name == "in" || function_name == "not_in") {
+ // Generating 'result_sign' from 'inlist' requires sorting the values.
std::set<std::string> values;
for (size_t i = 1; i < arguments.size(); i++) {
values.insert(block.get_by_position(arguments[i]).to_string(0));
diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h
index 31fcb6da447..4c6340e5b73 100644
--- a/be/src/vec/functions/function.h
+++ b/be/src/vec/functions/function.h
@@ -595,7 +595,7 @@ public:
auto function_name = function->get_name();
return function_name == "eq" || function_name == "ne" || function_name
== "lt" ||
function_name == "gt" || function_name == "le" || function_name
== "ge" ||
- function_name == "in";
+ function_name == "in" || function_name == "not_in";
}
bool is_deterministic_in_scope_of_query() const override {
diff --git a/regression-test/data/inverted_index_p0/test_index_rqg_bug3.out
b/regression-test/data/inverted_index_p0/test_index_rqg_bug3.out
new file mode 100644
index 00000000000..cd01bedc787
--- /dev/null
+++ b/regression-test/data/inverted_index_p0/test_index_rqg_bug3.out
@@ -0,0 +1,43 @@
+-- This file is automatically generated. You should know what you did if you
want to edit this
+-- !select_bug_1 --
+-10 2023-12-11
+-10 2023-12-12
+-10 2023-12-13
+-10 2023-12-15
+-10 2023-12-15
+-10 2023-12-19
+-10 2023-12-19
+-10 2024-01-17
+-10 2024-02-18
+-10 2024-02-18
+-10 2025-02-18
+-10 2026-01-18
+-10 2026-02-18
+-4 2023-12-10
+-4 2023-12-11
+-4 2023-12-16
+-4 2024-01-31
+0 2024-01-19
+1 2023-12-16
+1 2024-01-09
+2 2023-12-10
+2 2023-12-11
+2 2024-01-08
+2 2024-01-31
+3 2023-12-20
+3 2024-01-19
+3 2025-06-18
+3 2026-02-18
+3 2027-01-16
+4 2023-12-12
+4 2023-12-12
+4 2024-01-08
+5 2023-12-16
+6 2024-02-18
+7 2023-12-17
+7 2023-12-20
+7 2027-01-09
+8 2025-02-18
+9 2024-02-18
+9 2024-02-18
+
diff --git
a/regression-test/suites/inverted_index_p0/test_index_rqg_bug3.groovy
b/regression-test/suites/inverted_index_p0/test_index_rqg_bug3.groovy
new file mode 100644
index 00000000000..eb49100effd
--- /dev/null
+++ b/regression-test/suites/inverted_index_p0/test_index_rqg_bug3.groovy
@@ -0,0 +1,81 @@
+// 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_bug3", "test_index_rqg_bug3"){
+ def table1 = "test_index_rqg_bug3"
+
+ sql "drop table if exists ${table1}"
+
+ sql """
+ CREATE TABLE ${table1} (
+ `col_int_undef_signed_not_null` INT NOT NULL,
+ `col_date_undef_signed_not_null` 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_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_index_inverted` 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,
+ `pk` INT NULL,
+ 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
+ ) ENGINE=OLAP
+ UNIQUE KEY(`col_int_undef_signed_not_null`,
`col_date_undef_signed_not_null`,
`col_bigint_undef_signed_not_null_index_inverted`,
`col_bigint_undef_signed_not_null`)
+ DISTRIBUTED BY HASH(`col_bigint_undef_signed_not_null`) BUCKETS 1
+ PROPERTIES (
+ "replication_allocation" = "tag.location.default: 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_1 """
+ SELECT col_int_undef_signed_not_null, col_date_undef_signed_not_null
+ FROM ${table1} AS table1
+ WHERE (
+ NOT (
+ (
+ table1.`col_int_undef_signed_not_null` is NULL
+ )
+ OR table1.col_varchar_1024__undef_signed_index_inverted IN
('h', 'j')
+ )
+ OR table1.`col_date_undef_signed_not_null` IN ('2024-02-18')
+ )
+ ORDER BY col_int_undef_signed_not_null, col_date_undef_signed_not_null;
"""
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]