You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/08/03 01:27:54 UTC

[GitHub] [arrow-rs] viirya commented on a diff in pull request #2284: Clean up string casts and improve performance

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


##########
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:
   Personally I think `Time64MicrosecondType` is enough. But just nitpicking.



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