[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
This commit is contained in:
YueW
2023-04-08 15:45:08 +08:00
committed by GitHub
parent 25fba6b8b7
commit 0b8bc51b72
3 changed files with 60 additions and 0 deletions

View File

@ -1135,6 +1135,7 @@ Status OlapScanKeys::extend_scan_key(ColumnValueRange<primitive_type>& range,
_end_include = true;
*exact_value = false;
// not empty, do nothing
return Status::OK();
}
// 3.1 extend ScanKey with FixedValueRange

View File

@ -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']

View File

@ -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<string>,
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;"
}