waitingkuo commented on code in PR #3016:
URL: https://github.com/apache/arrow-rs/pull/3016#discussion_r1018344347


##########
arrow-cast/src/cast.rs:
##########
@@ -4090,6 +4291,160 @@ mod tests {
         assert!(c.is_null(2));
     }
 
+    #[test]
+    fn test_cast_timestamp_to_time64() {
+        // test timestamp secs
+        let a = TimestampSecondArray::from(vec![Some(86405), Some(1), None])
+            .with_timezone("+01:00".to_string());
+        let array = Arc::new(a) as ArrayRef;
+        let b = cast(&array, 
&DataType::Time64(TimeUnit::Microsecond)).unwrap();
+        let c = b.as_any().downcast_ref::<Time64MicrosecondArray>().unwrap();
+        assert_eq!(3605000000, c.value(0));
+        assert_eq!(3601000000, c.value(1));
+        assert!(c.is_null(2));
+        let b = cast(&array, &DataType::Time64(TimeUnit::Nanosecond)).unwrap();
+        let c = b.as_any().downcast_ref::<Time64NanosecondArray>().unwrap();
+        assert_eq!(3605000000000, c.value(0));
+        assert_eq!(3601000000000, c.value(1));
+        assert!(c.is_null(2));

Review Comment:
   casting timestamp<+1> to timestamp<None> simply drop the time zone from 
data_type
   while
   casting timestamp<+1> to time add this 1 hour into underline utc timestamp



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