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


##########
datafusion/physical-expr/src/expressions/negative.rs:
##########
@@ -288,6 +313,130 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn test_wrapping_negation_properties() {
+        let expr = NegativeExpr::new(Arc::new(Column::new("a", 0)));
+        let ordered = SortProperties::Ordered(Default::default());
+        for data_type in [Int8, Int16, Int32, Int64] {
+            let minimum = ScalarValue::min(&data_type).unwrap();
+            let full = Interval::make_unbounded(&data_type).unwrap();
+            let singleton = Interval::try_new(minimum.clone(), 
minimum.clone()).unwrap();
+            for range in [
+                full.clone(),
+                singleton.clone(),
+                Interval::try_new(ScalarValue::try_from(&data_type).unwrap(), 
minimum)
+                    .unwrap(),
+            ] {
+                let child = ExprProperties::new_unknown()
+                    .with_range(range.clone())
+                    .with_order(ordered);
+                let result = expr.get_properties(&[child]).unwrap();
+                assert_eq!(result.sort_properties, SortProperties::Unordered);
+                assert_eq!(result.range, full);
+                assert_eq!(expr.evaluate_bounds(&[&range]).unwrap(), full);
+                assert_eq!(
+                    expr.propagate_constraints(&range, &[&full]).unwrap(),
+                    Some(vec![full.clone()])
+                );
+            }
+            let child = ExprProperties::new_unknown()
+                .with_range(singleton)
+                .with_order(SortProperties::Singleton);
+            assert_eq!(
+                expr.get_properties(&[child]).unwrap().sort_properties,
+                SortProperties::Singleton
+            );
+        }
+    }
+
+    #[test]
+    fn test_non_wrapping_negation_properties() {

Review Comment:
   Could you add a one-sided signed interval whose lower bound is above `MIN` 
and whose upper bound is unbounded? That case cannot contain `MIN`, so it 
should still reverse the ordering and reflect the interval, which would guard 
against treating an unbounded upper bound as wrapping.



-- 
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