This is an automated email from the ASF dual-hosted git repository.
jianliangqi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 4a72ddc1fe6 [Fix](inverted index) fix fast execute for not_in expr
(#37745)
4a72ddc1fe6 is described below
commit 4a72ddc1fe67e658597f9b8ab3d0e56767f7d08a
Author: airborne12 <[email protected]>
AuthorDate: Mon Jul 15 19:43:26 2024 +0800
[Fix](inverted index) fix fast execute for not_in expr (#37745)
## Proposed changes
not_in predicate is not processed correctly in vin_predicate
fast_execute
---
be/src/vec/exprs/vexpr.cpp | 2 +-
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, 126 insertions(+), 2 deletions(-)
diff --git a/be/src/vec/exprs/vexpr.cpp b/be/src/vec/exprs/vexpr.cpp
index d788c8dc518..64a4adfa6be 100644
--- a/be/src/vec/exprs/vexpr.cpp
+++ b/be/src/vec/exprs/vexpr.cpp
@@ -627,7 +627,7 @@ 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++) {
diff --git a/be/src/vec/functions/function.h b/be/src/vec/functions/function.h
index f3af3870c2e..36558c11df0 100644
--- a/be/src/vec/functions/function.h
+++ b/be/src/vec/functions/function.h
@@ -521,7 +521,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";
}
Status eval_inverted_index(FunctionContext* context,
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]