Skip to content

Commit 15f2490

Browse files
authored
expr: Fix missing aggregate variants in is_constant and propagates_nonnull_constraint (#36061)
1 parent 16feb87 commit 15f2490

2 files changed

Lines changed: 53 additions & 4 deletions

File tree

src/expr/src/relation.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,8 @@ impl AggregateExpr {
24912491
/// Returns whether the expression has a constant result.
24922492
pub fn is_constant(&self) -> bool {
24932493
match self.func {
2494-
AggregateFunc::MaxInt16
2494+
AggregateFunc::MaxNumeric
2495+
| AggregateFunc::MaxInt16
24952496
| AggregateFunc::MaxInt32
24962497
| AggregateFunc::MaxInt64
24972498
| AggregateFunc::MaxUInt16
@@ -2505,6 +2506,9 @@ impl AggregateExpr {
25052506
| AggregateFunc::MaxDate
25062507
| AggregateFunc::MaxTimestamp
25072508
| AggregateFunc::MaxTimestampTz
2509+
| AggregateFunc::MaxInterval
2510+
| AggregateFunc::MaxTime
2511+
| AggregateFunc::MinNumeric
25082512
| AggregateFunc::MinInt16
25092513
| AggregateFunc::MinInt32
25102514
| AggregateFunc::MinInt64
@@ -2519,11 +2523,36 @@ impl AggregateExpr {
25192523
| AggregateFunc::MinDate
25202524
| AggregateFunc::MinTimestamp
25212525
| AggregateFunc::MinTimestampTz
2526+
| AggregateFunc::MinInterval
2527+
| AggregateFunc::MinTime
25222528
| AggregateFunc::Any
25232529
| AggregateFunc::All
25242530
| AggregateFunc::Dummy => self.expr.is_literal(),
25252531
AggregateFunc::Count => self.expr.is_literal_null(),
2526-
_ => self.expr.is_literal_err(),
2532+
AggregateFunc::SumInt16
2533+
| AggregateFunc::SumInt32
2534+
| AggregateFunc::SumInt64
2535+
| AggregateFunc::SumUInt16
2536+
| AggregateFunc::SumUInt32
2537+
| AggregateFunc::SumUInt64
2538+
| AggregateFunc::SumFloat32
2539+
| AggregateFunc::SumFloat64
2540+
| AggregateFunc::SumNumeric
2541+
| AggregateFunc::JsonbAgg { .. }
2542+
| AggregateFunc::JsonbObjectAgg { .. }
2543+
| AggregateFunc::MapAgg { .. }
2544+
| AggregateFunc::ArrayConcat { .. }
2545+
| AggregateFunc::ListConcat { .. }
2546+
| AggregateFunc::StringAgg { .. }
2547+
| AggregateFunc::RowNumber { .. }
2548+
| AggregateFunc::Rank { .. }
2549+
| AggregateFunc::DenseRank { .. }
2550+
| AggregateFunc::LagLead { .. }
2551+
| AggregateFunc::FirstValue { .. }
2552+
| AggregateFunc::LastValue { .. }
2553+
| AggregateFunc::FusedValueWindowFunc { .. }
2554+
| AggregateFunc::WindowAggregate { .. }
2555+
| AggregateFunc::FusedWindowAggregate { .. } => self.expr.is_literal_err(),
25272556
}
25282557
}
25292558

src/expr/src/relation/func.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2681,6 +2681,8 @@ impl AggregateFunc {
26812681
| AggregateFunc::MaxDate
26822682
| AggregateFunc::MaxTimestamp
26832683
| AggregateFunc::MaxTimestampTz
2684+
| AggregateFunc::MaxInterval
2685+
| AggregateFunc::MaxTime
26842686
| AggregateFunc::MinNumeric
26852687
| AggregateFunc::MinInt16
26862688
| AggregateFunc::MinInt32
@@ -2696,6 +2698,8 @@ impl AggregateFunc {
26962698
| AggregateFunc::MinDate
26972699
| AggregateFunc::MinTimestamp
26982700
| AggregateFunc::MinTimestampTz
2701+
| AggregateFunc::MinInterval
2702+
| AggregateFunc::MinTime
26992703
| AggregateFunc::SumInt16
27002704
| AggregateFunc::SumInt32
27012705
| AggregateFunc::SumInt64
@@ -2707,8 +2711,24 @@ impl AggregateFunc {
27072711
| AggregateFunc::SumNumeric
27082712
| AggregateFunc::StringAgg { .. } => true,
27092713
// Count is never null
2710-
AggregateFunc::Count => false,
2711-
_ => false,
2714+
AggregateFunc::Count
2715+
| AggregateFunc::Any
2716+
| AggregateFunc::All
2717+
| AggregateFunc::JsonbAgg { .. }
2718+
| AggregateFunc::JsonbObjectAgg { .. }
2719+
| AggregateFunc::MapAgg { .. }
2720+
| AggregateFunc::ArrayConcat { .. }
2721+
| AggregateFunc::ListConcat { .. }
2722+
| AggregateFunc::RowNumber { .. }
2723+
| AggregateFunc::Rank { .. }
2724+
| AggregateFunc::DenseRank { .. }
2725+
| AggregateFunc::LagLead { .. }
2726+
| AggregateFunc::FirstValue { .. }
2727+
| AggregateFunc::LastValue { .. }
2728+
| AggregateFunc::FusedValueWindowFunc { .. }
2729+
| AggregateFunc::WindowAggregate { .. }
2730+
| AggregateFunc::FusedWindowAggregate { .. }
2731+
| AggregateFunc::Dummy => false,
27122732
}
27132733
}
27142734
}

0 commit comments

Comments
 (0)