Skip to content

Commit

Permalink
p0
Browse files Browse the repository at this point in the history
  • Loading branch information
englefly committed Aug 7, 2024
1 parent fe39215 commit f52000d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down Expand Up @@ -174,6 +166,9 @@ suite("partition_prune") {
AS
${mv1}
""")

sql "analyze table test_duplicate with sync;"

explain {
sql("""${query1}""")
check {result ->
Expand Down Expand Up @@ -208,6 +203,9 @@ suite("partition_prune") {
AS
${mv2}
""")

sql "analyze table test_unique with sync;"

explain {
sql("""${query2}""")
check {result ->
Expand Down Expand Up @@ -254,6 +252,9 @@ suite("partition_prune") {
AS
${mv3}
""")

sql "analyze table test_aggregate with sync;"

explain {
sql("""${query3}""")
check {result ->
Expand Down
14 changes: 1 addition & 13 deletions regression-test/suites/mv_p0/ssb/q_2_1/q_2_1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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;"

Expand All @@ -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
Expand Down
16 changes: 1 addition & 15 deletions regression-test/suites/mv_p0/ssb/q_4_1/q_4_1.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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"
Expand Down Expand Up @@ -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})")
Expand All @@ -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
Expand Down Expand Up @@ -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'),
Expand All @@ -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
Expand Down

0 comments on commit f52000d

Please sign in to comment.