alamb commented on code in PR #2284:
URL: https://github.com/apache/arrow-rs/pull/2284#discussion_r936499391


##########
arrow/src/compute/kernels/cast.rs:
##########
@@ -1801,26 +1740,20 @@ fn cast_string_to_time64microsecond<Offset: 
OffsetSizeTrait>(
         //     The iterator is trustedLen because it comes from an 
`StringArray`.
         unsafe { Time64MicrosecondArray::from_trusted_len_iter(iter) }
     } else {
-        let vec = (0..string_array.len())
-            .map(|i| {
-                if string_array.is_null(i) {
-                    Ok(None)
-                } else {
-                    let string = string_array
-                        .value(i);
-
-                    let result = string
+        let vec = string_array.iter()
+            .map(|v| {
+                v.map(|v| {
+                    v
                         .parse::<chrono::NaiveTime>()
                         .map(|time| time.num_seconds_from_midnight() as i64 * 
MICROS_PER_SEC
-                            + time.nanosecond() as i64 / NANOS_PER_MICRO);
-
-                    Some(result.map_err(|_| {
-                        ArrowError::CastError(
-                            format!("Cannot cast string '{}' to value of 
arrow::datatypes::types::Time64MicrosecondType type", string),
-                        )
-                    }))
-                        .transpose()
-                }
+                             + time.nanosecond() as i64 / NANOS_PER_MICRO)
+                        .map_err(|_| {
+                            ArrowError::CastError(
+                                format!("Cannot cast string '{}' to value of 
arrow::datatypes::types::Time64MicrosecondType type", v),

Review Comment:
   I agree -- they are heinous -- here is a proposal to fix them: 
https://github.com/apache/arrow-rs/pull/2295 



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