diff --git a/regression-test/suites/mv_p0/partition_prune/partition_prune.groovy b/regression-test/suites/mv_p0/partition_prune/partition_prune.groovy index df7a20b358bffb2..c4b9c3c6a54554e 100644 --- a/regression-test/suites/mv_p0/partition_prune/partition_prune.groovy +++ b/regression-test/suites/mv_p0/partition_prune/partition_prune.groovy @@ -129,14 +129,6 @@ suite("partition_prune") { ('ag', 'bc', '2024-07-08 12:00:00', 10.1); """ - - multi_sql """ - analyze table test_unique with sync; - analyze table test_aggregate with sync; - analyze table test_duplicate with sync; - """ - - // test partition prune in duplicate table def mv1 = """ @@ -174,6 +166,9 @@ suite("partition_prune") { AS ${mv1} """) + + sql "analyze table test_duplicate with sync;" + explain { sql("""${query1}""") check {result -> @@ -208,6 +203,9 @@ suite("partition_prune") { AS ${mv2} """) + + sql "analyze table test_unique with sync;" + explain { sql("""${query2}""") check {result -> @@ -254,6 +252,9 @@ suite("partition_prune") { AS ${mv3} """) + + sql "analyze table test_aggregate with sync;" + explain { sql("""${query3}""") check {result -> diff --git a/regression-test/suites/mv_p0/ssb/q_2_1/q_2_1.groovy b/regression-test/suites/mv_p0/ssb/q_2_1/q_2_1.groovy index 05243be8ae6ebcf..718e87e2a1189ed 100644 --- a/regression-test/suites/mv_p0/ssb/q_2_1/q_2_1.groovy +++ b/regression-test/suites/mv_p0/ssb/q_2_1/q_2_1.groovy @@ -90,7 +90,6 @@ suite ("mv_ssb_q_2_1") { sql """INSERT INTO lineorder_flat (LO_ORDERDATE, LO_ORDERKEY, LO_LINENUMBER, LO_CUSTKEY, LO_PARTKEY, LO_SUPPKEY, LO_ORDERPRIORITY, LO_SHIPPRIORITY, LO_QUANTITY, LO_EXTENDEDPRICE, LO_ORDTOTALPRICE, LO_DISCOUNT, LO_REVENUE, LO_SUPPLYCOST, LO_TAX, LO_COMMITDATE, LO_SHIPMODE,C_NAME,C_ADDRESS,C_CITY,C_NATION,C_REGION,C_PHONE,C_MKTSEGMENT,S_NAME,S_ADDRESS,S_CITY,S_NATION,S_REGION,S_PHONE,P_NAME,P_MFGR,P_CATEGORY,P_BRAND,P_COLOR,P_TYPE,P_SIZE,P_CONTAINER) VALUES (19930101 , 2 , 2 , 2 , 2 , 2 ,'2',2 ,2 ,2 ,2 ,2 ,2 ,2 ,2 ,'2023-06-09','shipmode','name','address','city','nation','region','phone','mktsegment','name','address','city','nation','region','phone','name','mfgr','category','brand','color','type',4,'container');""" sql """analyze table lineorder_flat with sync;""" - sql """set enable_stats=false;""" qt_select_star "select * from lineorder_flat order by 1,2,P_MFGR;" @@ -104,18 +103,7 @@ suite ("mv_ssb_q_2_1") { ORDER BY YEAR, P_BRAND;""") contains "(lineorder_q_2_1)" } - sql """set enable_stats=true;""" - explain { - sql("""SELECT - SUM(LO_REVENUE), (LO_ORDERDATE DIV 10000) AS YEAR, - P_BRAND - FROM lineorder_flat - WHERE P_CATEGORY = 'MFGR#12' AND S_REGION = 'AMERICA' - GROUP BY YEAR, P_BRAND - ORDER BY YEAR, P_BRAND;""") - contains "(lineorder_q_2_1)" - } - + qt_select_mv """SELECT SUM(LO_REVENUE), (LO_ORDERDATE DIV 10000) AS YEAR, P_BRAND diff --git a/regression-test/suites/mv_p0/ssb/q_4_1/q_4_1.groovy b/regression-test/suites/mv_p0/ssb/q_4_1/q_4_1.groovy index 6e1124b5ad1019d..b10476922c25d72 100644 --- a/regression-test/suites/mv_p0/ssb/q_4_1/q_4_1.groovy +++ b/regression-test/suites/mv_p0/ssb/q_4_1/q_4_1.groovy @@ -91,7 +91,6 @@ suite ("mv_ssb_q_4_1") { qt_select_star "select * from lineorder_flat order by 1, 2, P_MFGR;" sql """analyze table lineorder_flat with sync;""" - sql """set enable_stats=false;""" explain { sql("""SELECT (LO_ORDERDATE DIV 10000) AS YEAR, @@ -116,20 +115,7 @@ suite ("mv_ssb_q_4_1") { AND P_MFGR IN ('MFGR#1', 'MFGR#2') GROUP BY YEAR, C_NATION ORDER BY YEAR ASC, C_NATION ASC;""" - sql """set enable_stats=true;""" - explain { - sql("""SELECT (LO_ORDERDATE DIV 10000) AS YEAR, - C_NATION, - SUM(LO_REVENUE - LO_SUPPLYCOST) AS profit - FROM lineorder_flat - WHERE - C_REGION = 'AMERICA' - AND S_REGION = 'AMERICA' - AND P_MFGR IN ('MFGR#1', 'MFGR#2') - GROUP BY YEAR, C_NATION - ORDER BY YEAR ASC, C_NATION ASC;""") - contains "(lineorder_q_4_1)" - } + sql""" drop materialized view lineorder_q_4_1 on lineorder_flat; """ qt_select """SELECT (LO_ORDERDATE DIV 10000) AS YEAR, diff --git a/regression-test/suites/nereids_rules_p0/mv/partition_mv_rewrite.groovy b/regression-test/suites/nereids_rules_p0/mv/partition_mv_rewrite.groovy index 79009a524cdd81e..afd9d81e5292f9c 100644 --- a/regression-test/suites/nereids_rules_p0/mv/partition_mv_rewrite.groovy +++ b/regression-test/suites/nereids_rules_p0/mv/partition_mv_rewrite.groovy @@ -327,12 +327,6 @@ suite("partition_mv_rewrite") { """ def ttl_mv_name = "mv_10000" - multi_sql """ - analyze table lineitem_static with sync; - analyze table lineitem with sync; - analyze table orders with sync; - """ - def create_ttl_mtmv = { db_name, mv_inner_name, mv_inner_sql -> sql """DROP MATERIALIZED VIEW IF EXISTS ${mv_inner_name}""" sql""" @@ -352,6 +346,12 @@ suite("partition_mv_rewrite") { create_ttl_mtmv(db, ttl_mv_name, ttl_mv_def_sql) + multi_sql """ + analyze table lineitem_static with sync; + analyze table lineitem with sync; + analyze table orders with sync; + """ + // test when mv is ttl // enable union rewrite sql "SET enable_materialized_view_rewrite=true" @@ -428,6 +428,13 @@ suite("partition_mv_rewrite") { """ waitingMTMVTaskFinished(getJobName(db, mv_name)) + + multi_sql """ + analyze table lineitem_static with sync; + analyze table lineitem with sync; + analyze table orders with sync; + """ + explain { sql("${roll_up_all_partition_sql}") contains("${mv_name}(${mv_name})") @@ -446,6 +453,12 @@ suite("partition_mv_rewrite") { sql "SET enable_materialized_view_rewrite=false" order_qt_query_17_0_before "${roll_up_all_partition_sql}" sql "SET enable_materialized_view_rewrite=true" + + multi_sql """ + analyze table lineitem_static with sync; + analyze table lineitem with sync; + analyze table orders with sync; + """ explain { sql("${roll_up_all_partition_sql}") // should rewrite successful when union rewrite enalbe if base table add new partition @@ -478,6 +491,7 @@ suite("partition_mv_rewrite") { // base table partition add data sql "REFRESH MATERIALIZED VIEW ${mv_name} AUTO" waitingMTMVTaskFinished(getJobName(db, mv_name)) + sql """ insert into lineitem values (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-11-21', '2023-11-21', '2023-11-21', 'd', 'd', 'yyyyyyyyy'), @@ -488,6 +502,13 @@ suite("partition_mv_rewrite") { sql "SET enable_materialized_view_rewrite=false" order_qt_query_19_0_before "${roll_up_all_partition_sql}" sql "SET enable_materialized_view_rewrite=true" + + + multi_sql """ + analyze table lineitem_static with sync; + analyze table lineitem with sync; + analyze table orders with sync; + """ explain { sql("${roll_up_all_partition_sql}") // should rewrite successful when union rewrite enalbe if base table add new partition