refactor: simplify hour_dyn() with time_fraction_dyn() (#4588)
diff --git a/arrow-arith/src/temporal.rs b/arrow-arith/src/temporal.rs
index 4d71316..ef551ce 100644
--- a/arrow-arith/src/temporal.rs
+++ b/arrow-arith/src/temporal.rs
@@ -181,26 +181,7 @@
/// 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 4c40e8b..9694cd2 100644
--- a/arrow-array/src/array/string_array.rs
+++ b/arrow-array/src/array/string_array.rs
@@ -154,7 +154,7 @@
/// let arr: LargeStringArray = std::iter::repeat(Some("foo")).take(10).collect();
/// ```
///
-/// Constructon and Access
+/// Construction and Access
///
/// ```
/// use arrow_array::LargeStringArray;