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


##########
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:
   Exactly. We have flexibility on the write path to decide whether/how we 
widen or convert values that don't exactly fit the variant type system, but 
readers expect the resulting types to always be valid variant shredding types.



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