You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "comphead (via GitHub)" <gi...@apache.org> on 2023/02/08 01:02:10 UTC

[GitHub] [arrow-rs] comphead commented on a diff in pull request #3673: Support UTF8 cast to Timestamp with timezone

comphead commented on code in PR #3673:
URL: https://github.com/apache/arrow-rs/pull/3673#discussion_r1099503179


##########
arrow-cast/src/cast.rs:
##########
@@ -168,7 +168,7 @@ pub fn can_cast_types(from_type: &DataType, to_type: &DataType) -> bool {
             | Time32(TimeUnit::Millisecond)
             | Time64(TimeUnit::Microsecond)
             | Time64(TimeUnit::Nanosecond)
-            | Timestamp(TimeUnit::Nanosecond, None)
+            | Timestamp(TimeUnit::Nanosecond, _)
         ) => true,

Review Comment:
   Done



##########
arrow-cast/src/cast.rs:
##########
@@ -7833,4 +7836,41 @@ mod tests {
         assert_eq!(v.value(0), 946728000000);
         assert_eq!(v.value(1), 1608035696000);
     }
+
+    #[test]
+    fn test_cast_utf8_to_timestamp() {
+        let valid = StringArray::from(vec![
+            "2023-01-01 04:05:06.789000-08:00",
+            "2023-01-01 04:05:06.789000-07:00",
+            "2023-01-01 04:05:06.789 -0800",
+            "2023-01-01 04:05:06.789 -08:00",
+            "2023-01-01 040506 +0730",
+            "2023-01-01 040506 +07:30",
+            "2023-01-01 04:05:06.789",
+            "2023-01-01 04:05:06",
+            "2023-01-01",
+        ]);
+
+        let array = Arc::new(valid) as ArrayRef;
+        let b = cast(
+            &array,
+            &DataType::Timestamp(TimeUnit::Nanosecond, Some("+00:00".to_string())),

Review Comment:
   Done



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