Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename weekday and weekday0 kernels to to num_days_from_monday and num_days_since_sunday #2066

Merged
merged 1 commit into from Jul 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions arrow/src/compute/kernels/temporal.rs
Expand Up @@ -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>,
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down