From 29e6ca9e1fb09f56396cbfe4ddbc6e313322b31a Mon Sep 17 00:00:00 2001 From: feiniaofeiafei Date: Thu, 19 Dec 2024 15:17:59 +0800 Subject: [PATCH] add regression --- .../partition_prune/always_mono_func.groovy | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/regression-test/suites/nereids_rules_p0/partition_prune/always_mono_func.groovy b/regression-test/suites/nereids_rules_p0/partition_prune/always_mono_func.groovy index 7fc74d7eb2ac6c1..81b934a2c2d26ca 100644 --- a/regression-test/suites/nereids_rules_p0/partition_prune/always_mono_func.groovy +++ b/regression-test/suites/nereids_rules_p0/partition_prune/always_mono_func.groovy @@ -125,11 +125,74 @@ suite("always_mono_func") { sql """ select * from always_mono_func where to_monday(dt) >= "2019-01-01" """ contains("partitions=2/5 (p4,p5)") } - + // year explain { sql """ select * from always_mono_func where year(dt) >= 2019 """ contains("partitions=3/5 (p3,p4,p5)") } + explain { + sql """select * from always_mono_func where year(dt) < 2019 and year(dt) > 2017""" + contains("partitions=2/5 (p2,p3)") + } + explain { + sql """select * from always_mono_func where year(dt) <2023""" + contains("partitions=5/5 (p1,p2,p3,p4,p5)") + } + // to_monday + explain { + sql """select * from always_mono_func where to_monday(dt) <'2019-01-01' """ + contains("partitions=4/5 (p1,p2,p3,p4)") + } + explain { + sql """select * from always_mono_func where to_monday(dt) ='2019-01-01' """ + contains("partitions=1/5 (p4)") + } + explain { + sql """select * from always_mono_func where to_monday(dt) >='2018-01-01' and to_monday(dt) <'2019-01-01' """ + contains("partitions=3/5 (p2,p3,p4)") + } + // to_date + explain { + sql """select * from always_mono_func where to_date(dt) <'2019-02-01' """ + contains("partitions=4/5 (p1,p2,p3,p4)") + } + explain { + sql """select * from always_mono_func where to_date(dt) <='2023-02-01' """ + contains("partitions=5/5 (p1,p2,p3,p4,p5)") + } + explain { + sql """select * from always_mono_func where to_date(dt) is null """ + contains("partitions=5/5 (p1,p2,p3,p4,p5)") + } + explain { + sql """select * from always_mono_func where to_date(dt) is not null """ + contains("partitions=5/5 (p1,p2,p3,p4,p5)") + } + explain { + sql """select * from always_mono_func where to_date(dt) >='2018-01-01' and to_date(dt) <'2019-01-01' """ + contains("partitions=2/5 (p2,p3)") + } + // last_day + explain { + sql """select * from always_mono_func where last_day(dt) <='2019-02-01' """ + contains("partitions=4/5 (p1,p2,p3,p4)") + } + explain { + sql """select * from always_mono_func where last_day(dt) <='2023-02-01' """ + contains("partitions=5/5 (p1,p2,p3,p4,p5)") + } + explain { + sql """select * from always_mono_func where last_day(dt) is null """ + contains("partitions=1/5 (p1)") + } + explain { + sql """select * from always_mono_func where last_day(dt) is not null """ + contains("partitions=5/5 (p1,p2,p3,p4,p5)") + } + explain { + sql """select * from always_mono_func where last_day(dt) >='2018-01-01' and last_day(dt) <'2019-01-01' """ + contains("partitions=2/5 (p2,p3)") + } explain { sql """select * from always_mono_func where date_format(to_monday(dt), 'yyyyMMdd') >= "20190101" """