Ted-Jiang commented on a change in pull request #1376:
URL: https://github.com/apache/arrow-rs/pull/1376#discussion_r817305221
##########
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:
Sorry for forgetting provide enough info.
PG has the same behavior.
```
postgres=# select extract('week' from date '2022-01-01');
date_part
-----------
52
(1 row)
```
It may cause by 2019/12/31 is Tuesday, i use `chronno` to calculate the
week it followed `ISO` standard.
--
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]