viirya commented on code in PR #6723:
URL: https://github.com/apache/arrow-datafusion/pull/6723#discussion_r1235808701


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -283,6 +283,11 @@ pub fn date_trunc(args: &[ColumnarValue]) -> 
Result<ColumnarValue> {
     Ok(match array {
         ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(v, tz_opt)) => {
             let nano = (f)(*v)?;
+
+            if nano.is_none() {
+                return Ok(ColumnarValue::Scalar(ScalarValue::Null));

Review Comment:
   The issue is because you use `ScalarValue::Null` here.
   
   You can take a look of `enum ScalarValue`. `ScalarValue::Null` is for 
`DataType::Null`. That's why there is an error for `a different schema`.
   
   For other types, they can take a `Some(value)` or a `None` which represents 
a null value for the type.
   
   For `TimestampNanosecond` type, you just need to put 
`ScalarValue::TimestampNanosecond` with `None` here.



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

Reply via email to