Skip to content

Commit

Permalink
add basic test for query rewrite by using mv
Browse files Browse the repository at this point in the history
  • Loading branch information
seawinde committed Aug 20, 2024
1 parent 308566b commit 0342422
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,17 @@
3 57.40 56.20 0 0
4 46.00 33.50 0 0

-- !query4_before --
2023-12-08 1 yy 1 \N 2
2023-12-09 1 yy 2 2 2
2023-12-10 1 yy 3 \N 2
2023-12-11 2 mm 4 \N 1
2023-12-12 2 mi 5 \N 2

-- !query4_after --
2023-12-08 1 yy 1 \N 2
2023-12-09 1 yy 2 2 2
2023-12-10 1 yy 3 \N 2
2023-12-11 2 mm 4 \N 1
2023-12-12 2 mi 5 \N 2

Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ suite("test_create_mtmv_contains_view","mtmv") {
DISTRIBUTED BY HASH(l_orderkey) BUCKETS 3
PROPERTIES (
"replication_num" = "1"
)
);
"""

sql """
Expand All @@ -101,7 +101,7 @@ suite("test_create_mtmv_contains_view","mtmv") {
DISTRIBUTED BY HASH(ps_partkey) BUCKETS 3
PROPERTIES (
"replication_num" = "1"
)
);
"""

sql """ insert into lineitem values
Expand Down Expand Up @@ -149,7 +149,7 @@ suite("test_create_mtmv_contains_view","mtmv") {
where o_orderdate = '2023-12-09'
group by
o_shippriority,
o_comment;;
o_comment;
"""

sql """
Expand Down Expand Up @@ -235,6 +235,46 @@ suite("test_create_mtmv_contains_view","mtmv") {
sql """drop view if exists `${view3_name}`"""
sql """drop materialized view if exists ${mv3_name};"""


def mv4_name = 'mv1';
def view4_name = 'view1';
sql """drop view if exists `${view4_name}`"""
// basic test for mv contain view for rewrite
sql"""
create view ${view4_name} as
select *
from
orders left
join lineitem on l_orderkey = o_orderkey;
"""

def mv4 = """
SELECT * from ${view4_name};
"""
def query4 = """
select
o_orderdate,
o_shippriority,
o_comment,
l_orderkey,
ps_partkey,
count(*)
from
orders left
join lineitem on l_orderkey = o_orderkey
left join partsupp on ps_partkey = l_orderkey
group by
o_orderdate,
o_shippriority,
o_comment,
l_orderkey,
ps_partkey;
"""
order_qt_query4_before "${query4}"
check_mv_rewrite_success(db, mv4, query4, mv4_name)
order_qt_query4_after "${query4}"
sql """ DROP MATERIALIZED VIEW IF EXISTS ${mv4_name}"""

sql """ drop table if exists orders;"""
sql """ drop table if exists lineitem;"""
sql """ drop table if exists partsupp;"""
Expand Down

0 comments on commit 0342422

Please sign in to comment.