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 2020/12/01 19:56:26 UTC

[GitHub] [arrow] yordan-pavlov commented on a change in pull request #8794: ARROW-10759: [Rust][DataFusion] Implement string to date cast

yordan-pavlov commented on a change in pull request #8794:
URL: https://github.com/apache/arrow/pull/8794#discussion_r533682639



##########
File path: rust/arrow/src/compute/kernels/cast.rs
##########
@@ -376,6 +378,27 @@ pub fn cast(array: &ArrayRef, to_type: &DataType) -> Result<ArrayRef> {
             Int64 => cast_string_to_numeric::<Int64Type>(array),
             Float32 => cast_string_to_numeric::<Float32Type>(array),
             Float64 => cast_string_to_numeric::<Float64Type>(array),
+            Date32(DateUnit::Day) => {
+                use chrono::{NaiveDate, NaiveTime};
+                let zero_time = NaiveTime::from_hms(0, 0, 0);
+                let string_array = array.as_any().downcast_ref::<StringArray>().unwrap();

Review comment:
       @andygrove thank you for taking the time to review this change; I absolutely agree with limiting use of unwrap() in general, but in this case because of `match (from_type, to_type) {` and then the specific case of `(Utf8, _) => match to_type {` it is unlikely that the cast of the array to cast to a `StringArray` will fail; or am I missing something?




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

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