You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "ozankabak (via GitHub)" <gi...@apache.org> on 2023/04/14 19:19:52 UTC

[GitHub] [arrow-datafusion] ozankabak commented on a diff in pull request #6007: Open/Closed bounds for interval arithmetic

ozankabak commented on code in PR #6007:
URL: https://github.com/apache/arrow-datafusion/pull/6007#discussion_r1167204148


##########
datafusion/physical-expr/src/intervals/interval_aritmetic.rs:
##########
@@ -324,25 +507,24 @@ mod tests {
                 Some(999),
                 Some(1000),
             ),
-            (None, Some(1000), Some(1000), None, Some(1000), Some(1000)), // singleton
             (None, None, None, None, None, None),
         ];
 
         for case in possible_cases {
             assert_eq!(
-                Interval {
-                    lower: ScalarValue::Int64(case.0),
-                    upper: ScalarValue::Int64(case.1)
-                }
-                .intersect(&Interval {
-                    lower: ScalarValue::Int64(case.2),
-                    upper: ScalarValue::Int64(case.3)
-                })?
+                Interval::new(
+                    IntervalBound::new(ScalarValue::Int64(case.0), true),
+                    IntervalBound::new(ScalarValue::Int64(case.1), true),
+                )
+                .intersect(&Interval::new(
+                    IntervalBound::new(ScalarValue::Int64(case.2), true),
+                    IntervalBound::new(ScalarValue::Int64(case.3), true)
+                ))?
                 .unwrap(),
-                Interval {
-                    lower: ScalarValue::Int64(case.4),
-                    upper: ScalarValue::Int64(case.5)
-                }
+                Interval::new(
+                    IntervalBound::new(ScalarValue::Int64(case.4), true),
+                    IntervalBound::new(ScalarValue::Int64(case.5), true),
+                )

Review Comment:
   ```rust
   assert_eq!(
     Interval::both_open(case.0, case.1)
     .intersect(&Interval::both_open(case.2, case.3)))?
     Interval::both_open(case.4, case.5 ),
   )
   ```
   
   I like this idea, let's add convenience functions `open_open`, `open_closed`, `closed_open` and `closed_closed` and use when appropriate (e.g. in tests).



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org