tustvold commented on code in PR #3183:
URL: https://github.com/apache/arrow-rs/pull/3183#discussion_r1032786484
##########
arrow-cast/src/display.rs:
##########
@@ -549,3 +553,34 @@ pub fn lexical_to_string<N: lexical_core::ToLexical>(n: N)
-> String {
String::from_utf8_unchecked(buf)
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn test_array_value_to_string_duration() {
+ let ns_array =
+ Arc::new(DurationNanosecondArray::from(vec![Some(1), None])) as
ArrayRef;
+ 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 =
+ Arc::new(DurationMicrosecondArray::from(vec![Some(1), None])) as
ArrayRef;
+ assert_eq!(array_value_to_string(&us_array, 0).unwrap(),
"PT0.000001S");
Review Comment:
I did some googling and this is the ISO8601 format for durations, and
therefore seems sensible to me. I just wanted to avoid some chrono-specific
format :smile:
--
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]