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/10/29 01:31:46 UTC

[GitHub] [arrow-datafusion] avantgardnerio commented on a diff in pull request #4004: Improve Error Handling and Readibility for downcasting `Date32Array`

avantgardnerio commented on code in PR #4004:
URL: https://github.com/apache/arrow-datafusion/pull/4004#discussion_r1008602783


##########
datafusion/row/src/writer.rs:
##########
@@ -326,8 +327,10 @@ pub(crate) fn write_field_date32(
     col_idx: usize,
     row_idx: usize,
 ) {
-    let from = from.as_any().downcast_ref::<Date32Array>().unwrap();
-    to.set_date32(col_idx, from.value(row_idx));
+    match as_date32_array(from) {
+        Ok(from) => to.set_date32(col_idx, from.value(row_idx)),
+        Err(e) => println!("{}", e),

Review Comment:
   IMO logging here is worse than unwrapping. The function is called `write_field_date32()` and if a date32 wasn't written to something, abending is preferable to carrying on in an in-determinant state. (of course, returning an `Err` `Result` would be even more preferable).



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