ch-sc commented on code in PR #14523:
URL: https://github.com/apache/datafusion/pull/14523#discussion_r1968018999


##########
datafusion/physical-expr/src/expressions/in_list.rs:
##########
@@ -398,6 +399,51 @@ impl PhysicalExpr for InListExpr {
             self.static_filter.clone(),
         )))
     }
+
+    /// The output interval is computed by checking if the list item intervals 
are
+    /// a subset of, overlap, or are disjoint with the input expression's 
interval.
+    ///
+    /// If [InListExpr::negated] is true, the output interval gets negated.
+    ///
+    /// # Example:
+    /// If the input expression's interval is a superset of the
+    /// conjunction of the list items intervals, the output
+    /// interval is [`Interval::CERTAINLY_TRUE`].
+    ///
+    /// ```text
+    /// interval of expr:   ....---------------------....
+    /// Some list items:    ..........|..|.....|.|.......
+    ///
+    /// output interval:    [`true`, `true`]
+    /// ```
+    fn evaluate_bounds(&self, children: &[&Interval]) -> Result<Interval> {
+        let expr_bounds = children[0];
+
+        debug_assert!(
+            children.len() >= 2,
+            "InListExpr requires at least one list item"
+        );
+
+        // conjunction of list item intervals
+        let list_bounds = children
+            .iter()
+            .skip(2)
+            .try_fold(children[1].clone(), |acc, item| acc.union(*item))?;
+
+        if self.negated {
+            expr_bounds.contains(list_bounds)?.boolean_negate()
+        } else {
+            expr_bounds.contains(list_bounds)

Review Comment:
   `contains` for `[3,5]` and `[0,9]` should return `UNCERTAIN`. I added a test 
with your example in in_list.rs.
   
   `CERTAINLY_TRUE` should only be returned if expr_bounds is a superset of the 
union of the list bounds. 



-- 
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-unsubscr...@datafusion.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to