Skip to content

Commit bca2f3a

Browse files
authored
Derive Copy for TimeUnit and IntervalUnit (apache#5840)
* Derive `Copy` for `TimeUnit` and `IntervalUnit` * Fix clippy warnings * Rustfmt
1 parent f42218a commit bca2f3a

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

arrow-cast/src/cast/mod.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ pub fn cast_with_options(
16601660
let array = cast_with_options(array, &Int64, cast_options)?;
16611661
Ok(make_timestamp_array(
16621662
array.as_primitive(),
1663-
unit.clone(),
1663+
*unit,
16641664
tz.clone(),
16651665
))
16661666
}
@@ -1721,11 +1721,7 @@ pub fn cast_with_options(
17211721
}
17221722
_ => converted,
17231723
};
1724-
Ok(make_timestamp_array(
1725-
&adjusted,
1726-
to_unit.clone(),
1727-
to_tz.clone(),
1728-
))
1724+
Ok(make_timestamp_array(&adjusted, *to_unit, to_tz.clone()))
17291725
}
17301726
(Timestamp(TimeUnit::Microsecond, _), Date32) => {
17311727
timestamp_to_date32(array.as_primitive::<TimestampMicrosecondType>())
@@ -4020,7 +4016,7 @@ mod tests {
40204016
TimeUnit::Microsecond,
40214017
TimeUnit::Nanosecond,
40224018
] {
4023-
let to_type = DataType::Timestamp(time_unit.clone(), None);
4019+
let to_type = DataType::Timestamp(*time_unit, None);
40244020
let b = cast(array, &to_type).unwrap();
40254021

40264022
match time_unit {

arrow-schema/src/datatype.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ pub enum DataType {
327327
}
328328

329329
/// An absolute length of time in seconds, milliseconds, microseconds or nanoseconds.
330-
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
330+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
331331
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
332332
pub enum TimeUnit {
333333
/// Time in seconds.
@@ -341,7 +341,7 @@ pub enum TimeUnit {
341341
}
342342

343343
/// YEAR_MONTH, DAY_TIME, MONTH_DAY_NANO interval in SQL style.
344-
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
344+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
345345
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
346346
pub enum IntervalUnit {
347347
/// Indicates the number of elapsed whole months, stored as 4-byte integers.

0 commit comments

Comments
 (0)