Skip to content

Commit 1915fcd

Browse files
authored
[test] (inverted index) add some regression cases (#42131)
## Proposed changes I cherry-picked the regression test cases for issues fixed in branch-2.0 and branch-2.1 to ensure the correctness of the master branch. #41200 #41297 #40425 #40630
1 parent ff1dd3d commit 1915fcd

8 files changed

+185
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
1
4+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
1
4+
5+
-- !sql_2 --
6+
3
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-- This file is automatically generated. You should know what you did if you want to edit this
2+
-- !sql --
3+
2
4+

regression-test/data/inverted_index_p0/test_need_read_data.out

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@
3131
-- !sql --
3232
1
3333

34+
-- !sql_11 --
35+
1
36+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
suite("test_index_rqg_bug5", "test_index_rqg_bug"){
19+
def table = "test_index_rqg_bug5"
20+
sql "drop table if exists ${table}"
21+
22+
sql """
23+
create table ${table} (
24+
pk int,
25+
col1 int not null,
26+
col2 bigint not null,
27+
INDEX col1_idx (`col1`) USING INVERTED,
28+
INDEX col2_idx (`col2`) USING INVERTED
29+
) engine=olap
30+
DUPLICATE KEY(pk, col1)
31+
distributed by hash(pk)
32+
properties("replication_num" = "1");;
33+
"""
34+
35+
sql """ insert into ${table} values (10, 20, 30); """
36+
37+
qt_sql """ select count() from ${table} where col2 + col1 > 20 or col1 > 20; """
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
suite("test_index_rqg_bug6", "test_index_rqg_bug"){
18+
def table = "test_index_rqg_bug6"
19+
20+
sql "drop table if exists ${table}"
21+
22+
sql """
23+
create table ${table} (
24+
pk int,
25+
col_int_undef_signed_index_inverted int not null ,
26+
col_varchar_1024__undef_signed_not_null varchar(1024) not null,
27+
INDEX col_int_undef_signed_index_inverted_idx (`col_int_undef_signed_index_inverted`) USING INVERTED,
28+
INDEX col_varchar_1024__undef_signed_not_null_idx (`col_varchar_1024__undef_signed_not_null`) USING INVERTED
29+
) engine=olap
30+
DUPLICATE KEY(pk)
31+
distributed by hash(pk) buckets 1
32+
properties("replication_num" = "1");
33+
"""
34+
35+
sql """ insert into ${table} values (10, 0, 'ok'), (11, 0, 'oo'), (12, 1, 'ok')"""
36+
37+
38+
sql """ sync"""
39+
sql """ set enable_inverted_index_query = true """
40+
sql """ set inverted_index_skip_threshold = 0 """
41+
qt_sql """
42+
SELECT
43+
count()
44+
FROM
45+
test_index_rqg_bug6
46+
WHERE
47+
IF(col_int_undef_signed_index_inverted = 0, 'true', 'false') = 'false'
48+
AND (
49+
col_varchar_1024__undef_signed_not_null LIKE 'ok'
50+
OR col_int_undef_signed_index_inverted = 0
51+
);
52+
"""
53+
54+
qt_sql_2 """
55+
SELECT
56+
count()
57+
FROM
58+
test_index_rqg_bug6
59+
WHERE
60+
col_varchar_1024__undef_signed_not_null LIKE 'ok'
61+
OR col_int_undef_signed_index_inverted = 0;
62+
"""
63+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
suite("test_index_rqg_bug7", "test_index_rqg_bug"){
18+
def table = "test_index_rqg_bug7"
19+
20+
sql "drop table if exists ${table}"
21+
22+
sql """
23+
create table ${table} (
24+
pk int,
25+
col_int_undef_signed int null ,
26+
col_int_undef_signed_not_null_index_inverted int not null ,
27+
INDEX col_int_undef_signed_not_null_index_inverted_idx (`col_int_undef_signed_not_null_index_inverted`) USING INVERTED
28+
) engine=olap
29+
DUPLICATE KEY(pk)
30+
distributed by hash(pk) buckets 10
31+
properties("replication_num" = "1");
32+
"""
33+
34+
sql """ insert into ${table} values (1, 7, 7), (2, 7, -2), (3, 4, -2)"""
35+
36+
37+
sql """ sync"""
38+
sql """ set enable_inverted_index_query = true """
39+
sql """ set inverted_index_skip_threshold = 0 """
40+
sql """ set enable_no_need_read_data_opt = true """
41+
qt_sql """
42+
select count(*) from ${table} where col_int_undef_signed_not_null_index_inverted = -2 AND ((CASE WHEN col_int_undef_signed_not_null_index_inverted = -2 THEN 1 ELSE NULL END = 1) OR col_int_undef_signed != 7);
43+
"""
44+
}

regression-test/suites/inverted_index_p0/test_need_read_data.groovy

+22
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,26 @@ suite("test_need_read_data", "p0"){
138138
sql "INSERT INTO ${indexTblName3} VALUES (1, 1),(1, -2),(1, -1);"
139139
qt_sql "SELECT /*+SET_VAR(enable_common_expr_pushdown=false,inverted_index_skip_threshold=100) */ id FROM ${indexTblName3} WHERE value<0 and abs(value)>1;"
140140
qt_sql "SELECT /*+SET_VAR(enable_common_expr_pushdown=true,inverted_index_skip_threshold=100) */ id FROM ${indexTblName3} WHERE value<0 and abs(value)>1;"
141+
142+
sql "DROP TABLE IF EXISTS tt"
143+
sql """
144+
CREATE TABLE `tt` (
145+
`a` int NULL,
146+
`b` varchar(20) NULL,
147+
`c` int NULL,
148+
INDEX idx_source (`b`) USING INVERTED,
149+
) ENGINE=OLAP
150+
DUPLICATE KEY(`a`, `b`)
151+
COMMENT 'OLAP'
152+
DISTRIBUTED BY RANDOM BUCKETS 1
153+
PROPERTIES (
154+
"replication_num" = "1"
155+
);
156+
"""
157+
sql """ insert into tt values (20, 'aa', 30); """
158+
sql """ insert into tt values (20, null, 30); """
159+
160+
qt_sql_11 """ select /*+SET_VAR(enable_count_on_index_pushdown=true) */ count(b) from tt where c = 30; """
161+
sql """ DROP TABLE IF EXISTS tt """
162+
141163
}

0 commit comments

Comments
 (0)