[Fix](inverted index) Fix wrong need read data opt when enable_common_expr_pushdown is disabled #40689 (#41101)

cherry pick from #40689
This commit is contained in:
airborne12
2024-09-23 14:21:30 +08:00
committed by GitHub
parent 059f822a3a
commit e175c63d41
2 changed files with 31 additions and 0 deletions

View File

@ -25,3 +25,9 @@
-- !sql4 --
2024-06-17T15:16:49 tengxun2
-- !sql --
1
-- !sql --
1

View File

@ -112,4 +112,29 @@ suite("test_need_read_data", "p0"){
qt_sql2 """ select * from ${indexTbName2} WHERE a >= '2024-06-15 00:00:00' AND b = 'tengxun2' and `b` match 'tengxun2' ; """
qt_sql3 """ select COUNT(1) from ${indexTbName2} WHERE a >= '2024-06-15 00:00:00' AND b like '%tengxun%' and `b` match 'tengxun2' ; """
qt_sql4 """ select * from ${indexTbName2} WHERE a >= '2024-06-15 00:00:00' AND b like '%tengxun%' and `b` match 'tengxun2' ; """
def indexTblName3 = "test_need_read_data_3"
sql "DROP TABLE IF EXISTS ${indexTblName3}"
// create 1 replica table
sql """
CREATE TABLE IF NOT EXISTS ${indexTblName3}(
`id` int(11) NOT NULL,
`value` int(11) NULL,
INDEX c_value_idx(`value`) USING INVERTED COMMENT ''
) ENGINE=OLAP
DUPLICATE KEY(`id`)
COMMENT 'OLAP'
DISTRIBUTED BY HASH(`id`) BUCKETS 1
PROPERTIES(
"replication_allocation" = "tag.location.default: 1"
);
"""
def var_result = sql "show variables"
logger.info("show variales result: " + var_result )
sql "INSERT INTO ${indexTblName3} VALUES (1, 1),(1, -2),(1, -1);"
qt_sql "SELECT /*+SET_VAR(enable_common_expr_pushdown=false) */ id FROM ${indexTblName3} WHERE value<0 and abs(value)>1;"
qt_sql "SELECT /*+SET_VAR(enable_common_expr_pushdown=true) */ id FROM ${indexTblName3} WHERE value<0 and abs(value)>1;"
}