Skip to content

Commit

Permalink
[test] (inverted index) add some regression cases (apache#42131)
Browse files Browse the repository at this point in the history
## 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.
apache#41200 apache#41297 apache#40425 apache#40630
  • Loading branch information
csun5285 authored Oct 22, 2024
1 parent ff1dd3d commit 1915fcd
Show file tree
Hide file tree
Showing 8 changed files with 185 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
1

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
1

-- !sql_2 --
3

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !sql --
2

Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@
-- !sql --
1

-- !sql_11 --
1

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// 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_bug5", "test_index_rqg_bug"){
def table = "test_index_rqg_bug5"
sql "drop table if exists ${table}"

sql """
create table ${table} (
pk int,
col1 int not null,
col2 bigint not null,
INDEX col1_idx (`col1`) USING INVERTED,
INDEX col2_idx (`col2`) USING INVERTED
) engine=olap
DUPLICATE KEY(pk, col1)
distributed by hash(pk)
properties("replication_num" = "1");;
"""

sql """ insert into ${table} values (10, 20, 30); """

qt_sql """ select count() from ${table} where col2 + col1 > 20 or col1 > 20; """
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// 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_bug6", "test_index_rqg_bug"){
def table = "test_index_rqg_bug6"

sql "drop table if exists ${table}"

sql """
create table ${table} (
pk int,
col_int_undef_signed_index_inverted int not null ,
col_varchar_1024__undef_signed_not_null varchar(1024) not null,
INDEX col_int_undef_signed_index_inverted_idx (`col_int_undef_signed_index_inverted`) USING INVERTED,
INDEX col_varchar_1024__undef_signed_not_null_idx (`col_varchar_1024__undef_signed_not_null`) USING INVERTED
) engine=olap
DUPLICATE KEY(pk)
distributed by hash(pk) buckets 1
properties("replication_num" = "1");
"""

sql """ insert into ${table} values (10, 0, 'ok'), (11, 0, 'oo'), (12, 1, 'ok')"""


sql """ sync"""
sql """ set enable_inverted_index_query = true """
sql """ set inverted_index_skip_threshold = 0 """
qt_sql """
SELECT
count()
FROM
test_index_rqg_bug6
WHERE
IF(col_int_undef_signed_index_inverted = 0, 'true', 'false') = 'false'
AND (
col_varchar_1024__undef_signed_not_null LIKE 'ok'
OR col_int_undef_signed_index_inverted = 0
);
"""

qt_sql_2 """
SELECT
count()
FROM
test_index_rqg_bug6
WHERE
col_varchar_1024__undef_signed_not_null LIKE 'ok'
OR col_int_undef_signed_index_inverted = 0;
"""
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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_bug7", "test_index_rqg_bug"){
def table = "test_index_rqg_bug7"

sql "drop table if exists ${table}"

sql """
create table ${table} (
pk int,
col_int_undef_signed int null ,
col_int_undef_signed_not_null_index_inverted int not null ,
INDEX col_int_undef_signed_not_null_index_inverted_idx (`col_int_undef_signed_not_null_index_inverted`) USING INVERTED
) engine=olap
DUPLICATE KEY(pk)
distributed by hash(pk) buckets 10
properties("replication_num" = "1");
"""

sql """ insert into ${table} values (1, 7, 7), (2, 7, -2), (3, 4, -2)"""


sql """ sync"""
sql """ set enable_inverted_index_query = true """
sql """ set inverted_index_skip_threshold = 0 """
sql """ set enable_no_need_read_data_opt = true """
qt_sql """
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);
"""
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,26 @@ suite("test_need_read_data", "p0"){
sql "INSERT INTO ${indexTblName3} VALUES (1, 1),(1, -2),(1, -1);"
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;"
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;"

sql "DROP TABLE IF EXISTS tt"
sql """
CREATE TABLE `tt` (
`a` int NULL,
`b` varchar(20) NULL,
`c` int NULL,
INDEX idx_source (`b`) USING INVERTED,
) ENGINE=OLAP
DUPLICATE KEY(`a`, `b`)
COMMENT 'OLAP'
DISTRIBUTED BY RANDOM BUCKETS 1
PROPERTIES (
"replication_num" = "1"
);
"""
sql """ insert into tt values (20, 'aa', 30); """
sql """ insert into tt values (20, null, 30); """

qt_sql_11 """ select /*+SET_VAR(enable_count_on_index_pushdown=true) */ count(b) from tt where c = 30; """
sql """ DROP TABLE IF EXISTS tt """

}

0 comments on commit 1915fcd

Please sign in to comment.