Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions regression-test/suites/rollup_p0/test_create_mv_and_mtmv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ suite("test_create_mv_and_mtmv") {
dt;

""")
// The MTMV must read the sync MV to cover partition-column resolution through the rollup.
explain {
sql("""
SELECT dt,advertiser,
SELECT /*+ use_mv(${tableName}.${mvName}) */ dt,advertiser,
count(DISTINCT user_id)
FROM ${tableName}
GROUP BY dt,advertiser""")
Expand All @@ -68,7 +69,7 @@ suite("test_create_mv_and_mtmv") {
DISTRIBUTED BY RANDOM BUCKETS 1
PROPERTIES ('replication_num' = '1')
AS
select dt, advertiser, count(distinct user_id)
select /*+ use_mv(${tableName}.${mvName}) */ dt, advertiser, count(distinct user_id)
from ${tableName}
group by dt, advertiser;
"""
Expand All @@ -94,6 +95,14 @@ AND RefreshMode = '${refreshMode}';"""
wait_mtmv_refresh_finish("COMPLETE")
qt_mtmv_init """ SELECT * FROM ${mtmvName} ORDER BY dt, advertiser"""

// Verify that the MTMV definition can build a rewrite cache and produce a rewrite candidate.
// The final CBO choice is intentionally not asserted because either valid plan may be cheaper.
mv_rewrite_success_without_check_chosen("""
SELECT dt, advertiser, count(distinct user_id)
FROM ${tableName}
GROUP BY dt, advertiser
""", mtmvName)

sql """INSERT INTO ${tableName} VALUES("2024-07-03",'b', "2024-07-03", 'b',2);"""
refreshTime = (int) (System.currentTimeMillis() / 1000L)
sql """REFRESH MATERIALIZED VIEW ${mtmvName} AUTO;"""
Expand All @@ -109,4 +118,4 @@ AND RefreshMode = '${refreshMode}';"""
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """ DROP MATERIALIZED VIEW IF EXISTS ${mtmvName} """

}
}
Loading