jayzhan211 commented on code in PR #25967:
URL: https://github.com/apache/datafusion/pull/25967#discussion_r4166060878


##########
datafusion/physical-expr/src/scalar_function.rs:
##########
@@ -527,6 +527,51 @@ mod tests {
         }
     }
 
+    #[test]
+    fn checked_time_arithmetic_uses_recovered_function_type() -> Result<()> {
+        use crate::expressions::BinaryExpr;
+        use arrow::compute::SortOptions;
+        use datafusion_expr::Operator;
+        use datafusion_functions::datetime::date_trunc::DateTruncFunc;
+
+        let time_type = DataType::Time64(TimeUnit::Nanosecond);
+        let precision = Arc::new(Literal::new(ScalarValue::from("hour")));
+        let precision_properties = precision.get_properties(&[])?;
+        let date_trunc = ScalarFunctionExpr::try_new(
+            Arc::new(ScalarUDF::from(DateTruncFunc::new())),
+            vec![precision, Arc::new(Column::new("t", 0))],
+            &Schema::new(vec![Field::new("t", time_type.clone(), true)]),
+            Arc::new(ConfigOptions::default()),
+        )?;
+        let time_properties = ExprProperties::new_unknown()
+            .with_order(SortProperties::Ordered(SortOptions::default()))
+            .with_range(Interval::make_unbounded(&time_type)?);
+        let truncated_properties =
+            date_trunc.get_properties(&[precision_properties, 
time_properties])?;
+        assert_eq!(

Review Comment:
   This only catches a missing recovery through `BinaryExpr`'s ordering result. 
If `BinaryExpr` later treats `Null`-typed operands conservatively, the test 
would pass without recovery. Pin the recovered type directly as well:
   
   ```suggestion
           assert_eq!(
               truncated_properties.range,
               Interval::make_unbounded(&time_type)?
           );
           assert_eq!(
   ```



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