This is an automated email from the ASF dual-hosted git repository.
tustvold pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/master by this push:
new 11445ee15 Rename `weekday` and `weekday0` kenrels to to
`num_days_from_monday` and `days_since_sunday` (#2066)
11445ee15 is described below
commit 11445ee1518dfbb4a58215cbc590baa2f3cd8702
Author: Andrew Lamb <[email protected]>
AuthorDate: Thu Jul 14 11:50:07 2022 -0400
Rename `weekday` and `weekday0` kenrels to to `num_days_from_monday` and
`days_since_sunday` (#2066)
---
arrow/src/compute/kernels/temporal.rs | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/arrow/src/compute/kernels/temporal.rs
b/arrow/src/compute/kernels/temporal.rs
index 593882423..efb828430 100644
--- a/arrow/src/compute/kernels/temporal.rs
+++ b/arrow/src/compute/kernels/temporal.rs
@@ -276,7 +276,9 @@ where
/// integers.
///
/// Monday is encoded as `0`, Tuesday as `1`, etc.
-pub fn weekday<T>(array: &PrimitiveArray<T>) -> Result<Int32Array>
+///
+/// See also [`num_days_from_sunday`] which starts at Sunday.
+pub fn num_days_from_monday<T>(array: &PrimitiveArray<T>) -> Result<Int32Array>
where
T: ArrowTemporalType + ArrowNumericType,
i64: std::convert::From<T::Native>,
@@ -309,10 +311,12 @@ where
}
/// Extracts the day of week of a given temporal array as an array of
-/// integers, starting at Sunday. This is different than [`weekday`] which
starts at Monday.
+/// integers, starting at Sunday.
///
/// Sunday is encoded as `0`, Monday as `1`, etc.
-pub fn weekday0<T>(array: &PrimitiveArray<T>) -> Result<Int32Array>
+///
+/// See also [`num_days_from_monday`] which starts at Monday.
+pub fn num_days_from_sunday<T>(array: &PrimitiveArray<T>) -> Result<Int32Array>
where
T: ArrowTemporalType + ArrowNumericType,
i64: std::convert::From<T::Native>,
@@ -632,7 +636,7 @@ mod tests {
let a: PrimitiveArray<Date64Type> =
vec![Some(1514764800000), None, Some(1550636625000)].into();
- let b = weekday(&a).unwrap();
+ let b = num_days_from_monday(&a).unwrap();
assert_eq!(0, b.value(0));
assert!(!b.is_valid(1));
assert_eq!(2, b.value(2));
@@ -651,7 +655,7 @@ mod tests {
]
.into();
- let b = weekday0(&a).unwrap();
+ let b = num_days_from_sunday(&a).unwrap();
assert_eq!(0, b.value(0));
assert!(!b.is_valid(1));
assert_eq!(1, b.value(2));