scovich commented on code in PR #8401:
URL: https://github.com/apache/arrow-rs/pull/8401#discussion_r2372253461


##########
parquet-variant-compute/src/variant_array.rs:
##########
@@ -864,6 +866,51 @@ fn typed_value_to_variant(typed_value: &ArrayRef, index: 
usize) -> Variant<'_, '
         DataType::Float64 => {
             primitive_conversion_single_value!(Float64Type, typed_value, index)
         }
+        DataType::Timestamp(timeunit, tz) => {
+            match (timeunit, tz) {
+                (TimeUnit::Microsecond, Some(_)) => {
+                    generic_conversion_single_value!(
+                        TimestampMicrosecondType,
+                        as_primitive,
+                        |v| DateTime::from_timestamp_micros(v).unwrap(),
+                        typed_value,
+                        index
+                    )
+                }
+                (TimeUnit::Microsecond, None) => {
+                    generic_conversion_single_value!(
+                        TimestampMicrosecondType,
+                        as_primitive,
+                        |v| 
DateTime::from_timestamp_micros(v).unwrap().naive_utc(),
+                        typed_value,
+                        index
+                    )
+                }
+                (TimeUnit::Nanosecond, Some(_)) => {
+                    generic_conversion_single_value!(
+                        TimestampNanosecondType,
+                        as_primitive,
+                        DateTime::from_timestamp_nanos,
+                        typed_value,
+                        index
+                    )
+                }
+                (TimeUnit::Nanosecond, None) => {
+                    generic_conversion_single_value!(
+                        TimestampNanosecondType,
+                        as_primitive,
+                        |v| DateTime::from_timestamp_nanos(v).naive_utc(),
+                        typed_value,
+                        index
+                    )
+                }
+                // Variant timestamp only support time unit with microsecond 
or nanosecond precision
+                _ => panic!(

Review Comment:
   Can we return an error instead of panicking?
   
   Also, AFAIK all the other timestamp precisions can be widened losslessly to 
microsecond; should we consider doing that instead of blowing up?



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