liukun4515 commented on a change in pull request #1376:
URL: https://github.com/apache/arrow-rs/pull/1376#discussion_r817371291
##########
File path: arrow/src/compute/kernels/temporal.rs
##########
@@ -334,6 +366,46 @@ mod tests {
assert_eq!(44, b.value(2));
}
+ #[test]
+ fn test_temporal_array_date32_week() {
+ let a: PrimitiveArray<Date32Type> = vec![Some(0), None,
Some(7)].into();
+
+ let b = week(&a).unwrap();
+ assert_eq!(1, b.value(0));
+ assert!(!b.is_valid(1));
+ assert_eq!(2, b.value(2));
+ }
+
+ #[test]
+ fn test_temporal_array_date64_week() {
+ // 1646116175000 -> 2022.03.01 , 1641171600000 -> 2022.01.03
+ // 1640998800000 -> 2022.01.01
+ let a: PrimitiveArray<Date64Type> = vec![
+ Some(1646116175000),
+ None,
+ Some(1641171600000),
+ Some(1640998800000),
+ ]
+ .into();
+
+ let b = week(&a).unwrap();
+ assert_eq!(9, b.value(0));
+ assert!(!b.is_valid(1));
+ assert_eq!(1, b.value(2));
+ assert_eq!(52, b.value(3));
Review comment:
> I don't understand how a date of `2022.01.01` would have a week of 52.
I wonder if the comments on what date `1640998800000` corresponds to is
incorrect?
@alamb
the week of `2022.01.01` belongs to the last year.
--
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]