psvri commented on code in PR #3183:
URL: https://github.com/apache/arrow-rs/pull/3183#discussion_r1031733918


##########
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:
   `chrono::Duration.to_string()` is displayed like that. We cannot use 
std::time::Duration here because arrow array duration can be negative. 
   
   IMHO is am very tempted to replace `P` and `T` chars and make the `S` as 
small to improve readability.
   
   



-- 
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]

Reply via email to