diff --git a/regression-test/data/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.out b/regression-test/data/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.out index 5a59b531a482d4..d02e2938633e82 100644 --- a/regression-test/data/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.out +++ b/regression-test/data/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.out @@ -1,35 +1,39 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !query1_0_before -- -b 3 +b 4 -- !query1_0_after -- -b 3 +b 4 -- !query1_1_before -- -b 3 +b 4 -- !query1_1_after -- -b 3 +b 4 -- !query1_1_0_before -- b b b +b -- !query1_1_0_after -- b b b +b -- !query1_1_1_before -- b b b +b -- !query1_1_1_after -- b b b +b -- !query1_2_before -- b 1 @@ -38,30 +42,34 @@ b 1 b 1 -- !query1_3_before -- -b 18 +b 21 -- !query1_3_after -- -b 18 +b 21 -- !query1_3_0_before -- b b b +b -- !query1_3_0_after -- b b b +b -- !query1_3_1_before -- b b b +b -- !query1_3_1_after -- b b b +b -- !query1_3_2_before -- b @@ -82,6 +90,9 @@ b b b b +b +b +b -- !query1_3_2_after -- b @@ -102,6 +113,9 @@ b b b b +b +b +b -- !query1_3_3_before -- b @@ -122,6 +136,9 @@ b b b b +b +b +b -- !query1_3_3_after -- b @@ -142,78 +159,89 @@ b b b b +b +b +b -- !query1_4_before -- -b 18 +b 21 -- !query1_4_after -- -b 18 +b 21 -- !query1_5_before -- -b 18 +b 21 -- !query1_5_after -- -b 18 +b 21 -- !query1_5_0_before -- b b b b +b -- !query1_5_0_after -- b b b b +b -- !query1_5_1_before -- b b b b +b -- !query1_5_1_after -- b b b b +b -- !query1_6_before -- -b 15 +b 18 -- !query1_6_after -- -b 15 +b 18 -- !query1_7_before -- -b 15 +b 18 -- !query1_7_after -- -b 15 +b 18 -- !query1_7_0_before -- b b b b +b -- !query1_7_0_after -- b b b b +b -- !query1_7_1_before -- b b b b +b -- !query1_7_1_after -- b b b b +b -- !query1_8_before -- b 6 @@ -260,20 +288,20 @@ b b -- !query1_10_before -- -b 21 -d 3 +b 25 +d 4 -- !query1_10_after -- -b 21 -d 3 +b 25 +d 4 -- !query1_11_before -- -b 21 -d 3 +b 25 +d 4 -- !query1_11_after -- -b 21 -d 3 +b 25 +d 4 -- !query1_11_0_before -- b @@ -297,6 +325,11 @@ b b b b +b +b +b +b +d d d d @@ -323,6 +356,11 @@ b b b b +b +b +b +b +d d d d @@ -349,6 +387,11 @@ b b b b +b +b +b +b +d d d d @@ -375,6 +418,11 @@ b b b b +b +b +b +b +d d d d @@ -424,20 +472,20 @@ b b -- !query1_14_before -- -b 24 -d 3 +b 28 +d 4 -- !query1_14_after -- -b 24 -d 3 +b 28 +d 4 -- !query1_15_before -- -b 24 -d 3 +b 28 +d 4 -- !query1_15_after -- -b 24 -d 3 +b 28 +d 4 -- !query1_15_0_before -- b @@ -464,6 +512,11 @@ b b b b +b +b +b +b +d d d d @@ -493,6 +546,11 @@ b b b b +b +b +b +b +d d d d @@ -522,6 +580,11 @@ b b b b +b +b +b +b +d d d d @@ -551,6 +614,11 @@ b b b b +b +b +b +b +d d d d @@ -566,64 +634,64 @@ b 6 -- !query2_1_after -- -- !query2_2_before -- -b 18 +b 21 -- !query2_2_after -- -b 18 +b 21 -- !query2_3_before -- -b 18 +b 21 -- !query2_3_after -- -b 18 +b 21 -- !query3_0_before -- -b 15 -d 3 +b 19 +d 4 -- !query3_0_after -- -b 15 -d 3 +b 19 +d 4 -- !query3_1_before -- -b 15 -d 3 +b 19 +d 4 -- !query3_1_after -- -b 15 -d 3 +b 19 +d 4 -- !query3_2_before -- -b 15 -d 3 +b 19 +d 4 -- !query3_2_after -- -b 15 -d 3 +b 19 +d 4 -- !query3_3_before -- -b 15 -d 3 +b 19 +d 4 -- !query3_3_after -- -b 15 -d 3 +b 19 +d 4 -- !query3_4_before -- -b 15 -d 3 +b 19 +d 4 -- !query3_4_after -- -b 15 -d 3 +b 19 +d 4 -- !query3_5_before -- -b 15 -d 3 +b 19 +d 4 -- !query3_5_after -- -b 15 -d 3 +b 19 +d 4 -- !query4_0_after -- b 2023-01-01 6 @@ -641,16 +709,42 @@ b 2023-04-01 b 2023-04-01 -- !query5_0_before -- -b 2023-10-17T00:00 3 +b 2023-10-17T00:00 4 -- !query5_0_after -- -b 2023-10-17T00:00 3 +b 2023-10-17T00:00 4 -- !query5_1_before -- b 2023-10-16T00:00 1 -b 2023-10-17T00:00 2 +b 2023-10-17T00:00 3 -- !query5_1_after -- b 2023-10-16T00:00 1 -b 2023-10-17T00:00 2 +b 2023-10-17T00:00 3 + +-- !query5_3_before -- +b 2023-10-01T17:09 1 +b 2023-10-01T19:10 1 +b 2023-10-01T21:11 1 +b 2023-10-15T00:00 2 +b 2023-10-15T23:59 1 +b 2023-10-16T00:00 2 +b 2023-10-16T23:59 1 +b 2023-10-17T00:00 3 +b 2023-10-17T23:59 1 +b 2023-10-18T00:00 3 +b 2023-10-18T23:59 1 + +-- !query5_3_after -- +b 2023-10-01T17:09 1 +b 2023-10-01T19:10 1 +b 2023-10-01T21:11 1 +b 2023-10-15T00:00 2 +b 2023-10-15T23:59 1 +b 2023-10-16T00:00 2 +b 2023-10-16T23:59 1 +b 2023-10-17T00:00 3 +b 2023-10-17T23:59 1 +b 2023-10-18T00:00 3 +b 2023-10-18T23:59 1 diff --git a/regression-test/suites/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.groovy b/regression-test/suites/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.groovy index 60681d0caa6c9e..115c39f8b503b3 100644 --- a/regression-test/suites/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.groovy +++ b/regression-test/suites/nereids_rules_p0/mv/date_trunc/mv_with_date_trunc.groovy @@ -76,18 +76,23 @@ suite("mv_with_date_trunc") { (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-01', '2023-10-01 21:11:23', '2023-10-01 21:11:23', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-15', '2023-10-15 00:00:00.000000', '2023-10-15 00:00:00.000000', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-15', '2023-10-15 00:00:00.000001', '2023-10-15 00:00:00.000001', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), + (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-15', '2023-10-15 00:00:00.000001', '2023-10-abcd', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-15', '2023-10-15 23:59:59.999999', '2023-10-15 23:59:59.999999', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-16', '2023-10-16 00:00:00', '2023-10-16 00:00:00', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-16', '2023-10-16 00:00:00.000001', '2023-10-16 00:00:00.000001', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), + (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-16', '2023-10-16 00:00:00.000001', '2023-10-abcd', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-16', '2023-10-16 23:59:59.999999', '2023-10-16 23:59:59.999999', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17 00:00:00.000000', '2023-10-17 00:00:00.000000', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17 00:00:00.000001', '2023-10-17 00:00:00.000001', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), + (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17 00:00:00.000001', '2023-10-17 00:abcd', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (1, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k', '2023-10-17', '2023-10-17 23:59:59.999999', '2023-10-17 23:59:59.999999', '2023-10-17', 'a', 'b', 'yyyyyyyyy'), (2, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k','2023-10-18', '2023-10-18 00:00:00.000000', '2023-10-18 00:00:00.000000', '2023-10-18', 'a', 'b', 'yyyyyyyyy'), (2, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k','2023-10-18', '2023-10-18 00:00:00.000001','2023-10-18 00:00:00.000001', '2023-10-18', 'a', 'b', 'yyyyyyyyy'), + (2, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k','2023-10-18', '2023-10-18 00:00:00.000001','2023-10-18 00:00:abcd', '2023-10-18', 'a', 'b', 'yyyyyyyyy'), (2, 2, 3, 4, 5.5, 6.5, 7.5, 8.5, 'o', 'k','2023-10-18', '2023-10-18 23:59:59.999999', '2023-10-18 23:59:59.999999', '2023-10-18', 'a', 'b', 'yyyyyyyyy'), (3, 2, 3, 6, 7.5, 8.5, 9.5, 10.5, 'k', 'o','2023-10-19', '2023-10-19 00:00:00','2023-10-19 00:00:00', '2023-10-19', 'c', 'd', 'xxxxxxxxx'), (3, 2, 3, 6, 7.5, 8.5, 9.5, 10.5, 'k', 'o','2023-10-19', '2023-10-19 00:00:00.000001','2023-10-19 00:00:00.000001','2023-10-19', 'c', 'd', 'xxxxxxxxx'), + (3, 2, 3, 6, 7.5, 8.5, 9.5, 10.5, 'k', 'o','2023-10-19', '2023-10-19 00:00:00.000001','2023-10-19 00:00:00.abcd','2023-10-19', 'c', 'd', 'xxxxxxxxx'), (3, 2, 3, 6, 7.5, 8.5, 9.5, 10.5, 'k', 'o','2023-10-19', '2023-10-19 23:59:59.999999','2023-10-19 23:59:59.999999', '2023-10-19', 'c', 'd', 'xxxxxxxxx'); """ @@ -1339,4 +1344,35 @@ suite("mv_with_date_trunc") { async_mv_rewrite_fail(db, mv5_1, query5_1, "mv5_1") order_qt_query5_1_after "${query5_1}" sql """ DROP MATERIALIZED VIEW IF EXISTS mv5_1""" + + + def mv5_3 = """ + select + l_shipmode, + date_trunc(l_commitdate_var, 'minute') as day_trunc, + count(*) + from + lineitem + group by + l_shipmode, + date_trunc(l_commitdate_var, 'minute'); + """ + def query5_3 = """ + select + l_shipmode, + date_trunc(l_commitdate_var, 'minute'), + count(*) + from + lineitem + where + l_commitdate_var >= cast('2023-10-01' as datetime) and l_commitdate_var < cast('2023-10-19' as datetime) + group by + l_shipmode, + date_trunc(l_commitdate_var, 'minute'); + """ + order_qt_query5_3_before "${query5_3}" + // data is not valid + async_mv_rewrite_success(db, mv5_3, query5_3, "mv5_3") + order_qt_query5_3_after "${query5_3}" + sql """ DROP MATERIALIZED VIEW IF EXISTS mv5_3""" }