Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zfr9527 committed Oct 25, 2024
1 parent 227f2eb commit bce071b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 129 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,14 @@ suite("mtmv_range_date_datetrunc_date_part_up") {
if (select_lists[i].replaceAll("`l_shipdate`", "").indexOf("l_shipdate") != -1) {
create_mv(mv_name, str, "l_shipdate", "day")
waitingMTMVTaskFinishedByMvName(mv_name)
explain {
sql("${str}")
contains "${mv_name}(${mv_name})"
}
mv_rewrite_success(str, mv_name)
compare_res(str + " order by 1,2,3")
}

if (select_lists[i].indexOf("col1") != -1) {
create_mv(mv_name, str, "col1", "day")
waitingMTMVTaskFinishedByMvName(mv_name)
explain {
sql("${str}")
contains "${mv_name}(${mv_name})"
}
mv_rewrite_success(str, mv_name)
compare_res(str + " order by 1,2,3")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ suite("mtmv_range_date_part_up_rewrite") {
for (int i = 0; i < mv_name_list.size(); i++) {
def job_name = getJobName(db, mv_name_list[i])
waitingMTMVTaskFinished(job_name)
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

Expand All @@ -178,56 +175,38 @@ suite("mtmv_range_date_part_up_rewrite") {
sql """insert into lineitem_range_date_union 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-01')"""
for (int i = 0; i < mv_name_list.size(); i++) {
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

for (int i = 0; i < mv_name_list.size(); i++) {
sql """refresh MATERIALIZED VIEW ${mv_name_list[i]} auto;"""
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

sql """insert into lineitem_range_date_union values
(2, null, 3, 1, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-18', '2023-10-18', 'a', 'b', 'yyyyyyyyy', '2023-11-01');"""
for (int i = 0; i < mv_name_list.size(); i++) {
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

for (int i = 0; i < mv_name_list.size(); i++) {
sql """refresh MATERIALIZED VIEW ${mv_name_list[i]} auto;"""
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

sql """ALTER TABLE lineitem_range_date_union DROP PARTITION IF EXISTS p4 FORCE"""
for (int i = 0; i < mv_name_list.size(); i++) {
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

for (int i = 0; i < mv_name_list.size(); i++) {
sql """refresh MATERIALIZED VIEW ${mv_name_list[i]} auto;"""
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ suite("mtmv_range_datetime_part_up_rewrite") {
for (int i = 0; i < mv_name_list.size(); i++) {
def job_name = getJobName(db, mv_name_list[i])
waitingMTMVTaskFinished(job_name)
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

Expand All @@ -178,56 +175,38 @@ suite("mtmv_range_datetime_part_up_rewrite") {
sql """insert into lineitem_range_datetime_union 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')"""
for (int i = 0; i < mv_name_list.size(); i++) {
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

for (int i = 0; i < mv_name_list.size(); i++) {
sql """refresh MATERIALIZED VIEW ${mv_name_list[i]} auto;"""
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

sql """insert into lineitem_range_datetime_union 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');"""
for (int i = 0; i < mv_name_list.size(); i++) {
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

for (int i = 0; i < mv_name_list.size(); i++) {
sql """refresh MATERIALIZED VIEW ${mv_name_list[i]} auto;"""
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

sql """ALTER TABLE lineitem_range_datetime_union DROP PARTITION IF EXISTS p4 FORCE"""
for (int i = 0; i < mv_name_list.size(); i++) {
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

for (int i = 0; i < mv_name_list.size(); i++) {
sql """refresh MATERIALIZED VIEW ${mv_name_list[i]} auto;"""
explain {
sql("${query_stmt_list[i]}")
contains "${mv_name_list[i]}(${mv_name_list[i]})"
}
mv_rewrite_success(query_stmt_list[i], mv_name_list[i])
compare_res(query_stmt_list[i] + " order by 1,2,3")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,9 @@ suite ("partition_curd_union_rewrite") {
"""
// wait partition is invalid
sleep(5000)
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
compare_res(all_partition_sql + order_by_stmt)
explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
compare_res(partition_sql + order_by_stmt)

sql "REFRESH MATERIALIZED VIEW ${mv_name} AUTO"
Expand All @@ -197,15 +191,9 @@ suite ("partition_curd_union_rewrite") {
"""
// Wait partition is invalid
sleep(5000)
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
compare_res(all_partition_sql + order_by_stmt)
explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
compare_res(partition_sql + order_by_stmt)

// Test when base table delete partition test
Expand All @@ -215,14 +203,8 @@ suite ("partition_curd_union_rewrite") {
"""
// Wait partition is invalid
sleep(3000)
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
compare_res(all_partition_sql + order_by_stmt)
explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
compare_res(partition_sql + order_by_stmt)
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,9 @@ suite ("partition_curd_union_rewrite_hive") {
waitingMTMVTaskFinished(getJobName(db, mv_name))

// All partition is valid, test query and rewrite by materialized view
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
compare_res(all_partition_sql + order_by_stmt)
explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
compare_res(partition_sql + order_by_stmt)

// Part partition is invalid, test can not use partition 2023-10-17 to rewrite
Expand All @@ -224,30 +218,17 @@ suite ("partition_curd_union_rewrite_hive") {
"""
// wait partition is invalid
sleep(5000)
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
assertTrue(compare_res(all_partition_sql + order_by_stmt) == false)
explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
assertTrue(compare_res(all_partition_sql + order_by_stmt) == false)


sql "REFRESH MATERIALIZED VIEW ${mv_name} AUTO"
waitingMTMVTaskFinished(getJobName(db, mv_name))
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
compare_res(all_partition_sql + order_by_stmt)

explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
compare_res(partition_sql + order_by_stmt)


Expand All @@ -258,29 +239,17 @@ suite ("partition_curd_union_rewrite_hive") {
"""
// Wait partition is invalid
sleep(5000)
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
assertTrue(compare_res(all_partition_sql + order_by_stmt) == false)
explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
compare_res(partition_sql + order_by_stmt)

// Test when base table delete partition test
sql "REFRESH MATERIALIZED VIEW ${mv_name} AUTO"
waitingMTMVTaskFinished(getJobName(db, mv_name))
explain {
sql("${all_partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(all_partition_sql, mv_name)
compare_res(all_partition_sql + order_by_stmt)
explain {
sql("${partition_sql}")
contains("${mv_name}(${mv_name})")
}
mv_rewrite_success(partition_sql, mv_name)
compare_res(partition_sql + order_by_stmt)

}
Expand Down

0 comments on commit bce071b

Please sign in to comment.