Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](case)fix range_datetime_part_up_rewrite case failed #47302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ suite("mtmv_range_datetime_part_up_rewrite") {
sql "SET enable_materialized_view_nest_rewrite=true"
sql "SET enable_materialized_view_union_rewrite=true"
sql "SET enable_nereids_timeout = false"
String mv_prefix = "range_datetime_up_union"

String mv_prefix = "mtmv_range_datetime_part_up_rewrite"
String lineitemName = "${mv_prefix}_lineitem"
String ordersName = "${mv_prefix}_orders"
sql """
drop table if exists lineitem_range_datetime_union
drop table if exists ${lineitemName}
"""

sql """CREATE TABLE `lineitem_range_datetime_union` (
sql """CREATE TABLE `${lineitemName}` (
`l_orderkey` BIGINT NULL,
`l_linenumber` INT NULL,
`l_partkey` INT NULL,
Expand Down Expand Up @@ -61,10 +62,10 @@ suite("mtmv_range_datetime_part_up_rewrite") {
);"""

sql """
drop table if exists orders_range_datetime_union
drop table if exists ${ordersName}
"""

sql """CREATE TABLE `orders_range_datetime_union` (
sql """CREATE TABLE `${ordersName}` (
`o_orderkey` BIGINT NULL,
`o_custkey` INT NULL,
`o_orderstatus` VARCHAR(1) NULL,
Expand All @@ -89,7 +90,7 @@ suite("mtmv_range_datetime_part_up_rewrite") {
);"""

sql """
insert into lineitem_range_datetime_union values
insert into ${lineitemName} values
(null, 1, 2, 3, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17', 'a', 'b', 'yyyyyyyyy', '2023-10-29 00:00:00'),
(1, null, 3, 1, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-18', '2023-10-18', 'a', 'b', 'yyyyyyyyy', '2023-10-29 00:00:00'),
(3, 3, null, 2, 7.5, 8.5, 9.5, 10.5, 'k', 'o', '2023-10-19', '2023-10-19', 'c', 'd', 'xxxxxxxxx', '2023-10-29 02:00:00'),
Expand All @@ -98,10 +99,10 @@ suite("mtmv_range_datetime_part_up_rewrite") {
(3, 1, 1, 2, 7.5, 8.5, 9.5, 10.5, 'k', 'o', '2023-10-19', null, 'c', 'd', 'xxxxxxxxx', '2023-10-29 02:00:00'),
(1, 3, 2, 2, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17', 'a', 'b', 'yyyyyyyyy', '2023-10-29 00:00:00');
"""
sql """alter table lineitem_range_datetime_union modify column l_comment set stats ('row_count'='7');"""
sql """alter table ${lineitemName} modify column l_comment set stats ('row_count'='7');"""

sql """
insert into orders_range_datetime_union values
insert into ${ordersName} values
(null, 1, 'k', 99.5, 'a', 'b', 1, 'yy', '2023-10-29 00:00:00'),
(1, null, 'o', 109.2, 'c','d',2, 'mm', '2023-10-29 00:00:00'),
(3, 3, null, 99.5, 'a', 'b', 1, 'yy', '2023-10-29 01:00:00'),
Expand All @@ -113,18 +114,18 @@ suite("mtmv_range_datetime_part_up_rewrite") {
(3, 2, 'k', 99.5, 'a', 'b', 1, 'yy', '2023-10-29 00:00:00'),
(4, 5, 'k', 99.5, 'a', 'b', 1, 'yy', '2023-10-29 02:00:00');
"""
sql """alter table orders_range_datetime_union modify column o_comment set stats ('row_count'='10');"""
sql """alter table ${ordersName} modify column o_comment set stats ('row_count'='10');"""

sql """DROP MATERIALIZED VIEW if exists ${mv_prefix}_mv1;"""
sql """CREATE MATERIALIZED VIEW ${mv_prefix}_mv1 BUILD IMMEDIATE REFRESH AUTO ON MANUAL partition by(date_trunc(`col1`, 'month')) DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS
select date_trunc(`l_shipdate`, 'day') as col1, l_shipdate, l_orderkey from lineitem_range_datetime_union as t1 left join orders_range_datetime_union as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey;"""
select date_trunc(`l_shipdate`, 'day') as col1, l_shipdate, l_orderkey from ${lineitemName} as t1 left join ${ordersName} as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey;"""

sql """DROP MATERIALIZED VIEW if exists ${mv_prefix}_mv2;"""
sql """CREATE MATERIALIZED VIEW ${mv_prefix}_mv2 BUILD IMMEDIATE REFRESH AUTO ON MANUAL partition by(date_trunc(`col1`, 'month')) DISTRIBUTED BY RANDOM BUCKETS 2 PROPERTIES ('replication_num' = '1') AS
select date_trunc(`l_shipdate`, 'hour') as col1, l_shipdate, l_orderkey from lineitem_range_datetime_union as t1 left join orders_range_datetime_union as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey;"""
select date_trunc(`l_shipdate`, 'hour') as col1, l_shipdate, l_orderkey from ${lineitemName} as t1 left join ${ordersName} as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey;"""

def sql1 = """select date_trunc(`l_shipdate`, 'day') as col1, l_shipdate, l_orderkey from lineitem_range_datetime_union as t1 left join orders_range_datetime_union as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey"""
def sql2 = """select date_trunc(`l_shipdate`, 'hour') as col1, l_shipdate, l_orderkey from lineitem_range_datetime_union as t1 left join orders_range_datetime_union as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey"""
def sql1 = """select date_trunc(`l_shipdate`, 'day') as col1, l_shipdate, l_orderkey from ${lineitemName} as t1 left join ${ordersName} as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey"""
def sql2 = """select date_trunc(`l_shipdate`, 'hour') as col1, l_shipdate, l_orderkey from ${lineitemName} as t1 left join ${ordersName} as t2 on t1.l_orderkey = t2.o_orderkey group by col1, l_shipdate, l_orderkey"""

def localWaitingMTMVTaskFinished = { def jobName ->
Thread.sleep(2000);
Expand Down Expand Up @@ -173,10 +174,10 @@ suite("mtmv_range_datetime_part_up_rewrite") {
}


sql """alter table lineitem_range_datetime_union add partition p4 values [("2023-11-29 03:00:00"), ("2023-11-29 04:00:00"));"""
sql """insert into lineitem_range_datetime_union values
sql """alter table ${lineitemName} add partition p4 values [("2023-11-29 03:00:00"), ("2023-11-29 04:00:00"));"""
sql """insert into ${lineitemName} values
(1, null, 3, 1, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-18', '2023-10-18', 'a', 'b', 'yyyyyyyyy', '2023-11-29 03:00:00')"""
sql """alter table lineitem_range_datetime_union modify column l_comment set stats ('row_count'='8');"""
sql """alter table ${lineitemName} modify column l_comment set stats ('row_count'='8');"""
for (int i = 0; i < mv_name_list.size(); i++) {
// both mv should rewrite success
mv_rewrite_any_success(query_stmt_list[i], mv_name_list)
Expand All @@ -190,9 +191,9 @@ suite("mtmv_range_datetime_part_up_rewrite") {
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

sql """insert into lineitem_range_datetime_union values
sql """insert into ${lineitemName} values
(3, null, 3, 1, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-18', '2023-10-18', 'a', 'b', 'yyyyyyyyy', '2023-11-29 03:00:00');"""
sql """alter table lineitem_range_datetime_union modify column l_comment set stats ('row_count'='9');"""
sql """alter table ${lineitemName} modify column l_comment set stats ('row_count'='9');"""
for (int i = 0; i < mv_name_list.size(); i++) {
// both mv should rewrite success
mv_rewrite_any_success(query_stmt_list[i], mv_name_list)
Expand All @@ -206,7 +207,7 @@ suite("mtmv_range_datetime_part_up_rewrite") {
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

sql """ALTER TABLE lineitem_range_datetime_union DROP PARTITION IF EXISTS p4 FORCE"""
sql """ALTER TABLE ${lineitemName} DROP PARTITION IF EXISTS p4 FORCE"""
for (int i = 0; i < mv_name_list.size(); i++) {
// both mv should rewrite success
mv_rewrite_any_success(query_stmt_list[i], mv_name_list)
Expand Down
Loading