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/04/11 10:02:05 UTC

[GitHub] [arrow-rs] yjshen opened a new pull request, #1534: Enable Date32/64 to String/LargeString cast

yjshen opened a new pull request, #1534:
URL: https://github.com/apache/arrow-rs/pull/1534

   # Which issue does this PR close?
   
   <!---
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   # Rationale for this change
    
   Date32/64 to String/LargeString cast is missing
   
   # What changes are included in this PR?
   
   `can_cast` as well as `cast` methods.
   
   # Are there any user-facing changes?
   
   Yes, now possible to cast date to string.


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


[GitHub] [arrow-rs] alamb commented on a diff in pull request #1534: Enable Date32/64 to String/LargeString cast

Posted by GitBox <gi...@apache.org>.
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [arrow-rs] alamb merged pull request #1534: Add support for Date32/64 <--> String/LargeString in `cast` kernel

Posted by GitBox <gi...@apache.org>.
alamb merged PR #1534:
URL: https://github.com/apache/arrow-rs/pull/1534


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