kosiew commented on code in PR #25629:
URL: https://github.com/apache/datafusion/pull/25629#discussion_r4267600168


##########
datafusion/expr-common/src/interval_arithmetic.rs:
##########
@@ -2594,6 +2619,54 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn test_next_prev_value_composite_intervals() -> Result<()> {
+        use ScalarValue::{IntervalDayTime as DayTime, IntervalMonthDayNano as 
MDN};
+        use arrow::datatypes::{IntervalDayTime, IntervalMonthDayNano};
+        let day_time = |days, ms| DayTime(Some(IntervalDayTime::new(days, 
ms)));
+        let mdn = |months, days, nanos| {
+            MDN(Some(IntervalMonthDayNano::new(months, days, nanos)))
+        };
+
+        // The smallest component carries into the next one at its bound.
+        assert_eq!(next_value(day_time(0, i32::MAX)), day_time(1, i32::MIN));
+        assert_eq!(prev_value(day_time(1, i32::MIN)), day_time(0, i32::MAX));
+        assert_eq!(next_value(mdn(0, 0, i64::MAX)), mdn(0, 1, i64::MIN));
+        assert_eq!(prev_value(mdn(0, 1, i64::MIN)), mdn(0, 0, i64::MAX));
+        assert_eq!(
+            next_value(mdn(0, i32::MAX, i64::MAX)),
+            mdn(1, i32::MIN, i64::MIN)
+        );
+        assert_eq!(
+            prev_value(mdn(1, i32::MIN, i64::MIN)),
+            mdn(0, i32::MAX, i64::MAX)
+        );
+
+        assert_eq!(next_value(day_time(3, 7)), day_time(3, 8));
+        assert_eq!(prev_value(mdn(3, 2, 1)), mdn(3, 2, 0));
+
+        assert_eq!(
+            next_value(DayTime(Some(IntervalDayTime::MAX))),
+            DayTime(None)
+        );
+        assert_eq!(
+            prev_value(DayTime(Some(IntervalDayTime::MIN))),
+            DayTime(None)
+        );
+        assert_eq!(next_value(MDN(Some(IntervalMonthDayNano::MAX))), 
MDN(None));
+        assert_eq!(prev_value(MDN(Some(IntervalMonthDayNano::MIN))), 
MDN(None));
+
+        // The reproduction from #25573: strict propagation needed the 
successor

Review Comment:
   Could we move the `satisfy_greater` reproduction into its own named test? If 
the fix regresses, the earlier `next_value` assertion would panic before this 
case runs, so a separate test would make the propagation failure easier to 
diagnose.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to