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


##########
arrow/src/compute/kernels/cast.rs:
##########
@@ -1300,6 +1306,44 @@ where
     ))
 }
 
+/// Cast date32 types to Utf8/LargeUtf8
+fn cast_date32_to_string<OffsetSize: StringOffsetSizeTrait>(
+    array: &ArrayRef,
+) -> Result<ArrayRef> {
+    let array = array.as_any().downcast_ref::<Date32Array>().unwrap();
+
+    Ok(Arc::new(
+        (0..array.len())
+            .map(|ix| {
+                if array.is_null(ix) {
+                    None
+                } else {
+                    array.value_as_date(ix).map(|v| v.to_string())
+                }
+            })
+            .collect::<GenericStringArray<OffsetSize>>(),
+    ))

Review Comment:
   It would be cool tou se `iter()` on the array which would be faster and more 
idomatic. However I see there is no great way to call `value_as_date()` without 
an `Date32Array`



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