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 1e0f02ffc0 refactor: simplify hour_dyn() with time_fraction_dyn()
(#4588)
1e0f02ffc0 is described below
commit 1e0f02ffc0619cbdc2cfd184573dc1eecd0f61a2
Author: jakevin <[email protected]>
AuthorDate: Sun Jul 30 22:11:11 2023 +0800
refactor: simplify hour_dyn() with time_fraction_dyn() (#4588)
---
arrow-arith/src/temporal.rs | 21 +--------------------
arrow-array/src/array/string_array.rs | 2 +-
2 files changed, 2 insertions(+), 21 deletions(-)
diff --git a/arrow-arith/src/temporal.rs b/arrow-arith/src/temporal.rs
index 4d713161a7..ef551ceedd 100644
--- a/arrow-arith/src/temporal.rs
+++ b/arrow-arith/src/temporal.rs
@@ -181,26 +181,7 @@ pub fn using_chrono_tz_and_utc_naive_date_time(
/// the range of [0, 23]. If the given array isn't temporal primitive or
dictionary array,
/// an `Err` will be returned.
pub fn hour_dyn(array: &dyn Array) -> Result<ArrayRef, ArrowError> {
- match array.data_type().clone() {
- DataType::Dictionary(_, _) => {
- downcast_dictionary_array!(
- array => {
- let hour_values = hour_dyn(array.values())?;
- Ok(Arc::new(array.with_values(&hour_values)))
- }
- dt => return_compute_error_with!("hour does not support", dt),
- )
- }
- _ => {
- downcast_temporal_array!(
- array => {
- hour(array)
- .map(|a| Arc::new(a) as ArrayRef)
- }
- dt => return_compute_error_with!("hour does not support", dt),
- )
- }
- }
+ time_fraction_dyn(array, "hour", |t| t.hour() as i32)
}
/// Extracts the hours of a given temporal primitive array as an array of
integers within
diff --git a/arrow-array/src/array/string_array.rs
b/arrow-array/src/array/string_array.rs
index 4c40e8b90c..9694cd2d4e 100644
--- a/arrow-array/src/array/string_array.rs
+++ b/arrow-array/src/array/string_array.rs
@@ -154,7 +154,7 @@ pub type StringArray = GenericStringArray<i32>;
/// let arr: LargeStringArray =
std::iter::repeat(Some("foo")).take(10).collect();
/// ```
///
-/// Constructon and Access
+/// Construction and Access
///
/// ```
/// use arrow_array::LargeStringArray;