alamb commented on code in PR #4557:
URL: https://github.com/apache/arrow-rs/pull/4557#discussion_r1271318312
##########
arrow-cast/src/display.rs:
##########
@@ -534,20 +534,20 @@ temporal_display!(time64us_to_time, time_format,
Time64MicrosecondType);
temporal_display!(time64ns_to_time, time_format, Time64NanosecondType);
macro_rules! duration_display {
- ($convert:ident, $t:ty) => {
+ ($unit:expr, $t:ty) => {
impl<'a> DisplayIndex for &'a PrimitiveArray<$t> {
fn write(&self, idx: usize, f: &mut dyn Write) -> FormatResult {
- write!(f, "{}", $convert(self.value(idx)))?;
+ write!(f, concat!("{} ", $unit), self.value(idx))?;
Ok(())
}
}
};
}
-duration_display!(duration_s_to_duration, DurationSecondType);
-duration_display!(duration_ms_to_duration, DurationMillisecondType);
-duration_display!(duration_us_to_duration, DurationMicrosecondType);
-duration_display!(duration_ns_to_duration, DurationNanosecondType);
+duration_display!("secs", DurationSecondType);
+duration_display!("millis", DurationMillisecondType);
+duration_display!("micros", DurationMicrosecondType);
+duration_display!("nanos", DurationNanosecondType);
Review Comment:
I need to do some research here --
for example, given 1000ms I think many users would like to see `1 sec`. I
realize there are details of why this may not always be totally accurately for
larger durations...
Maybe something like `1.032 sec` could be used to represent the unit (based
on number of decimal places...)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]