alamb commented on code in PR #6738:
URL: https://github.com/apache/arrow-datafusion/pull/6738#discussion_r1237330210


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -284,44 +284,34 @@ pub fn date_trunc(args: &[ColumnarValue]) -> 
Result<ColumnarValue> {
         ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(v, tz_opt)) => {
             let nano = (f)(*v)?;
 
-            if nano.is_none() {
-                return 
Ok(ColumnarValue::Scalar(ScalarValue::TimestampNanosecond(
-                    None,
-                    tz_opt.clone(),
-                )));
-            }
-
             match granularity.as_str() {
                 "minute" => {
                     // trunc to minute
                     let second = ScalarValue::TimestampNanosecond(
-                        Some(nano.unwrap() / 1_000_000_000 * 1_000_000_000),
+                        nano.map(|nano| nano / 1_000_000_000 * 1_000_000_000),

Review Comment:
   since `nano` is already an option, we can skip the check/unwrap using 
`Option::map`



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