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/05/25 05:28:40 UTC

[GitHub] [arrow-rs] HaoYang670 commented on a diff in pull request #1738: Support casting `Utf8` to `Boolean`

HaoYang670 commented on code in PR #1738:
URL: https://github.com/apache/arrow-rs/pull/1738#discussion_r881229487


##########
arrow/src/compute/kernels/cast.rs:
##########
@@ -1661,6 +1660,34 @@ fn cast_string_to_timestamp_ns<Offset: OffsetSizeTrait>(
     Ok(Arc::new(array) as ArrayRef)
 }
 
+/// Casts Utf8 to Boolean
+fn cast_utf8_to_boolean(from: &ArrayRef, cast_options: &CastOptions) -> Result<ArrayRef> {
+    let array = from.as_any().downcast_ref::<StringArray>().unwrap();

Review Comment:
   ```suggestion
       let array = from.as_any().downcast_ref::<StringArray>().ok_or_else(|| {
           ArrowError::ComputeError(" cannot cast the array to StringArray")
       })?;
   ```



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