From e175c63d416cc28d9d9f6df3c08bbe948dfc82fe Mon Sep 17 00:00:00 2001 From: airborne12 Date: Mon, 23 Sep 2024 14:21:30 +0800 Subject: [PATCH] [Fix](inverted index) Fix wrong need read data opt when enable_common_expr_pushdown is disabled #40689 (#41101) cherry pick from #40689 --- .../inverted_index_p0/test_need_read_data.out | 6 +++++ .../test_need_read_data.groovy | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/regression-test/data/inverted_index_p0/test_need_read_data.out b/regression-test/data/inverted_index_p0/test_need_read_data.out index 7298254f83..782d5e5ab0 100644 --- a/regression-test/data/inverted_index_p0/test_need_read_data.out +++ b/regression-test/data/inverted_index_p0/test_need_read_data.out @@ -25,3 +25,9 @@ -- !sql4 -- 2024-06-17T15:16:49 tengxun2 +-- !sql -- +1 + +-- !sql -- +1 + diff --git a/regression-test/suites/inverted_index_p0/test_need_read_data.groovy b/regression-test/suites/inverted_index_p0/test_need_read_data.groovy index 321c95fe32..2e8294d4cf 100644 --- a/regression-test/suites/inverted_index_p0/test_need_read_data.groovy +++ b/regression-test/suites/inverted_index_p0/test_need_read_data.groovy @@ -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;" }