You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "alamb (via GitHub)" <gi...@apache.org> on 2023/06/21 17:10:33 UTC

[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6738: Minor: remove some uses of unwrap

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: github-unsubscribe@arrow.apache.org

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