alamb commented on code in PR #4557:
URL: https://github.com/apache/arrow-rs/pull/4557#discussion_r1272039668
##########
arrow-cast/src/display.rs:
##########
@@ -889,23 +903,39 @@ mod tests {
#[test]
fn test_array_value_to_string_duration() {
- let ns_array = DurationNanosecondArray::from(vec![Some(1), None]);
- assert_eq!(
- array_value_to_string(&ns_array, 0).unwrap(),
- "PT0.000000001S"
- );
- assert_eq!(array_value_to_string(&ns_array, 1).unwrap(), "");
-
- let us_array = DurationMicrosecondArray::from(vec![Some(1), None]);
- assert_eq!(array_value_to_string(&us_array, 0).unwrap(),
"PT0.000001S");
- assert_eq!(array_value_to_string(&us_array, 1).unwrap(), "");
-
- let ms_array = DurationMillisecondArray::from(vec![Some(1), None]);
- assert_eq!(array_value_to_string(&ms_array, 0).unwrap(), "PT0.001S");
- assert_eq!(array_value_to_string(&ms_array, 1).unwrap(), "");
-
- let s_array = DurationSecondArray::from(vec![Some(1), None]);
- assert_eq!(array_value_to_string(&s_array, 0).unwrap(), "PT1S");
- assert_eq!(array_value_to_string(&s_array, 1).unwrap(), "");
+ let values = vec![
+ Some(1),
+ None,
+ Some(-1),
+ Some(1_000_000_000),
+ Some(-1_000_000_000),
+ ];
+ let a = DurationNanosecondArray::from(values.clone());
+ assert_eq!(array_value_to_string(&a, 0).unwrap(), "0.000000001 secs");
+ assert_eq!(array_value_to_string(&a, 1).unwrap(), "");
+ assert_eq!(array_value_to_string(&a, 2).unwrap(), "-0.000000001 secs");
+ assert_eq!(array_value_to_string(&a, 3).unwrap(), "1.000000000 secs");
+ assert_eq!(array_value_to_string(&a, 4).unwrap(), "-1.000000000 secs");
Review Comment:
If trailing zeros are stripped we wouldn't know what the duration precision
was, for what it is worth
--
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]