watford-ep commented on code in PR #18342:
URL: https://github.com/apache/datafusion/pull/18342#discussion_r2478236979


##########
datafusion/expr-common/src/interval_arithmetic.rs:
##########
@@ -583,7 +583,10 @@ impl Interval {
                     upper: ScalarValue::Boolean(Some(upper)),
                 })
             }
-            _ => internal_err!("Incompatible data types for logical 
conjunction"),
+            // TODO: bounds MAY be certain if either LHS or RHS is certainly 
false
+
+            // Return UNCERTAIN when intervals don't have concrete boolean 
bounds
+            _ => Ok(Self::UNCERTAIN),

Review Comment:
   Very interesting...I started by adding tests for and/or:
   ```rust
   #[test]
   fn test_and_null_boolean_intervals() -> Result<()> {
       let null_interval =
           Interval::try_new(ScalarValue::Boolean(None), 
ScalarValue::Boolean(None))?;
   
       let and_result = null_interval.and(&Interval::CERTAINLY_FALSE)?;
       assert_eq!(and_result, Interval::CERTAINLY_FALSE);
   
       let and_result = null_interval.and(&Interval::CERTAINLY_TRUE)?;
       assert_eq!(and_result, Interval::UNCERTAIN);
   
       let and_result = null_interval.and(&null_interval)?;
       assert_eq!(and_result, Interval::UNCERTAIN);
   
       Ok(())
   }
   
   #[test]
   fn test_or_null_boolean_intervals() -> Result<()> {
       let null_interval =
           Interval::try_new(ScalarValue::Boolean(None), 
ScalarValue::Boolean(None))?;
   
       let or_result = null_interval.or(&Interval::CERTAINLY_FALSE)?;
       assert_eq!(or_result, Interval::UNCERTAIN);
   
       let or_result = null_interval.or(&Interval::CERTAINLY_TRUE)?;
       assert_eq!(or_result, Interval::CERTAINLY_TRUE);
   
       let or_result = null_interval.or(&null_interval)?;
       assert_eq!(or_result, Interval::UNCERTAIN);
   
       Ok(())
   }
   ```
   And they already worked without any code changes, so I think my TODO 
statements were premature and unnecessary.



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