From 0b8bc51b72ba5c893cb3a40389a2a48b95eb161f Mon Sep 17 00:00:00 2001 From: YueW <45946325+Tanya-W@users.noreply.github.com> Date: Sat, 8 Apr 2023 15:45:08 +0800 Subject: [PATCH] [fix](inverted index) Fix key column match query failed (#18436) * [fix](inverted index) Fix key column match query failed * [chore](regression case) add regression case * [fix] fix regression case no order by --- be/src/exec/olap_common.h | 1 + .../test_index_key_match_select.out | 10 ++++ .../test_index_key_match_select.groovy | 49 +++++++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 regression-test/data/inverted_index_p0/test_index_key_match_select.out create mode 100644 regression-test/suites/inverted_index_p0/test_index_key_match_select.groovy diff --git a/be/src/exec/olap_common.h b/be/src/exec/olap_common.h index 2ea304b7b9..d0b6191927 100644 --- a/be/src/exec/olap_common.h +++ b/be/src/exec/olap_common.h @@ -1135,6 +1135,7 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange& range, _end_include = true; *exact_value = false; // not empty, do nothing + return Status::OK(); } // 3.1 extend ScanKey with FixedValueRange diff --git a/regression-test/data/inverted_index_p0/test_index_key_match_select.out b/regression-test/data/inverted_index_p0/test_index_key_match_select.out new file mode 100644 index 0000000000..c968dd49cd --- /dev/null +++ b/regression-test/data/inverted_index_p0/test_index_key_match_select.out @@ -0,0 +1,10 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- +u1 ['u2', 'u3'] +u2 ['u1', 'u3', 'u4'] + +-- !sql -- +u1 ['u2', 'u3'] +u2 ['u1', 'u3', 'u4'] +u3 ['u1'] + diff --git a/regression-test/suites/inverted_index_p0/test_index_key_match_select.groovy b/regression-test/suites/inverted_index_p0/test_index_key_match_select.groovy new file mode 100644 index 0000000000..dc04ba8786 --- /dev/null +++ b/regression-test/suites/inverted_index_p0/test_index_key_match_select.groovy @@ -0,0 +1,49 @@ +// 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_key_match_select", "inverted_index_select"){ + def indexTbName1 = "index_key_match_select" + def varchar_colume1 = "user" + def array_string_colume2 = "followers" + + sql "DROP TABLE IF EXISTS ${indexTbName1}" + + // create table with different index + sql """ + CREATE TABLE IF NOT EXISTS ${indexTbName1} ( + ${varchar_colume1} varchar(500), + ${array_string_colume2} array, + INDEX ${varchar_colume1}_idx(${varchar_colume1}) USING INVERTED PROPERTIES("parser"="english") COMMENT '${varchar_colume1} index', + INDEX ${array_string_colume2}_idx(${array_string_colume2}) USING INVERTED PROPERTIES("parser"="english") COMMENT '${array_string_colume2} index' + ) + DUPLICATE KEY(`user`) + DISTRIBUTED BY HASH(`user`) BUCKETS 10 + properties("replication_num" = "1"); + """ + + // insert data + // ${varchar_colume1}, ${array_string_colume2} + // user, followers + sql """ insert into ${indexTbName1} VALUES + ("u1", ["u2","u3"]), + ("u2", ["u1","u3","u4"]), + ("u3", ["u1"]), + ("u4", ["u3"]) + """ + qt_sql "SELECT * FROM ${indexTbName1} WHERE user MATCH_ANY 'u1, u2' ORDER BY user LIMIT 10;" + qt_sql "SELECT * FROM ${indexTbName1} WHERE user MATCH_ANY 'u1, u2, u3' ORDER BY user LIMIT 10;" +} \ No newline at end of file