diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java index e0eeece6b300c06..740363b50aad2b8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayCeil.java @@ -118,8 +118,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new DayCeil(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java index 804658ce984fa95..5ba7fc13c7526b8 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/DayFloor.java @@ -118,8 +118,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new DayFloor(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java index 4c8a98ca9fd025c..13358e18d747705 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourCeil.java @@ -112,8 +112,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new HourCeil(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java index 1148c3191612f0f..f48e26ea443f251 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/HourFloor.java @@ -112,8 +112,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new HourFloor(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java index 55e34cd14355658..4f3e317d00ef39c 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteCeil.java @@ -111,8 +111,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new MinuteCeil(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java index 7aab30162aa14fc..cefb5222c764ad5 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MinuteFloor.java @@ -111,8 +111,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new MinuteFloor(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java index 7d3514610d49ea7..a1f4628dd6a9abc 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthCeil.java @@ -118,8 +118,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new MonthCeil(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java index f2535a674ddc94f..d55d52ab68ce5a9 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/MonthFloor.java @@ -118,8 +118,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new MonthFloor(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java index b530cff9bfc8c94..3b0e657698743aa 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondCeil.java @@ -112,8 +112,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new SecondCeil(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java index 806aad402220a5d..c06fff06aed0162 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/SecondFloor.java @@ -113,8 +113,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new SecondFloor(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java index 19a7626d5721d1a..37c952af815d861 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearCeil.java @@ -117,8 +117,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new YearCeil(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java index 06f7894768ae786..00a1ad918f7ffa7 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java +++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/scalar/YearFloor.java @@ -117,8 +117,7 @@ public Expression withConstantArgs(Expression literal) { case 3: return new YearFloor(literal, child(1), child(2)); default: - // should not reach - return null; + throw new IllegalStateException("The function " + getName() + " has invalid child number."); } } } diff --git a/regression-test/suites/nereids_rules_p0/partition_prune/test_add_sub_diff_ceil_floor.groovy b/regression-test/suites/nereids_rules_p0/partition_prune/test_add_sub_diff_ceil_floor.groovy index 12ddff6eb0ec8b2..8582dad9ec7b27c 100644 --- a/regression-test/suites/nereids_rules_p0/partition_prune/test_add_sub_diff_ceil_floor.groovy +++ b/regression-test/suites/nereids_rules_p0/partition_prune/test_add_sub_diff_ceil_floor.groovy @@ -272,7 +272,7 @@ suite("test_add_sub_diff_ceil_floor") { } explain { sql "select * from test_add_sub_diff_ceil_floor_t where years_diff('2021-01-01',month_ceil(hours_sub(dt, 1))) <=2" - contains("partitions=3/5 (p3,p4,p5)") + contains("partitions=4/5 (p1,p3,p4,p5)") } // mixed with non-function predicates explain { @@ -293,4 +293,21 @@ suite("test_add_sub_diff_ceil_floor") { sql """select * from test_add_sub_diff_ceil_floor_t where hours_add(dt, years_diff(dt,'2018-01-01')) <'2018-01-01' """ contains("partitions=5/5 (p1,p2,p3,p4,p5)") } + + // max + sql "drop table if exists max_t" + sql """create table max_t (a int, dt datetime, d date, c varchar(100)) duplicate key(a) + partition by range(dt) ( + partition p1 values less than ("2017-01-01"), + partition p2 values less than ("2018-01-01"), + partition p3 values less than ("2019-01-01"), + partition p4 values less than ("2020-01-01"), + partition p5 values less than ("2021-01-01"), + partition p6 values less than MAX + ) distributed by hash(a) properties("replication_num"="1");""" + sql """INSERT INTO max_t SELECT number, + date_add('2016-01-01 00:00:00', interval number month), + cast(date_add('2022-01-01 00:00:00', interval number month) as date), cast(number as varchar(65533)) FROM numbers('number'='100');""" + sql "INSERT INTO max_t values(3,null,null,null);" + } \ No newline at end of file