alamb commented on code in PR #8114:
URL: https://github.com/apache/arrow-rs/pull/8114#discussion_r2271191599


##########
parquet-variant-json/src/to_json.rs:
##########
@@ -457,6 +472,20 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn test_time_to_json() -> Result<(), ArrowError> {
+        let naive_time = NaiveTime::from_num_seconds_from_midnight_opt(12345, 
123460708).unwrap();
+        let variant = Variant::Time(naive_time);
+        let json = variant_to_json_string(&variant)?;
+        assert!(json.contains("03:25:45.12346"));
+        assert!(json.starts_with('"') && json.ends_with('"'));
+
+        let json_value = variant_to_json_value(&variant)?;
+        assert!(matches!(json_value, Value::String(_)));
+        println!("{:?}", json);

Review Comment:
   perhaps the println is left over



##########
parquet-variant-compute/src/cast_to_variant.rs:
##########
@@ -151,6 +154,75 @@ pub fn cast_to_variant(input: &dyn Array) -> 
Result<VariantArray, ArrowError> {
         DataType::FixedSizeBinary(_) => {
             cast_conversion_nongeneric!(as_fixed_size_binary, |v| v, input, 
builder);
         }
+        DataType::Time32(unit) => {

Review Comment:
   this logic looks good to me -- thank you



##########
parquet-variant/src/variant.rs:
##########
@@ -248,6 +248,8 @@ pub enum Variant<'m, 'v> {
     Binary(&'v [u8]),
     /// Primitive (type_id=1): STRING
     String(&'v str),
+    /// Primitive (type_id=1): TIME(isAdjustedToUTC=false, MICROS)
+    Time(NaiveTime),

Review Comment:
   I wonder if we should keep the isAdjustedToUTC information here? And if it 
is adjusted to UTC, perhaps we should use the `Utc` from chrono 🤔 



##########
parquet-variant-json/src/to_json.rs:
##########
@@ -457,6 +472,20 @@ mod tests {
         Ok(())
     }
 
+    #[test]
+    fn test_time_to_json() -> Result<(), ArrowError> {
+        let naive_time = NaiveTime::from_num_seconds_from_midnight_opt(12345, 
123460708).unwrap();
+        let variant = Variant::Time(naive_time);
+        let json = variant_to_json_string(&variant)?;
+        assert!(json.contains("03:25:45.12346"));

Review Comment:
   I wonder if there is a reason not to compare the output json string directly 
(why look for contains and starts/ends)? One thing a full compare would do is 
output the actual value in any failure message



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to