klion26 commented on code in PR #8950:
URL: https://github.com/apache/arrow-rs/pull/8950#discussion_r2587267482


##########
parquet-variant-compute/src/type_conversion.rs:
##########
@@ -84,14 +84,87 @@ impl_primitive_from_variant!(datatypes::UInt64Type, as_u64);
 impl_primitive_from_variant!(datatypes::Float16Type, as_f16);
 impl_primitive_from_variant!(datatypes::Float32Type, as_f32);
 impl_primitive_from_variant!(datatypes::Float64Type, as_f64);
-impl_primitive_from_variant!(
-    datatypes::Date32Type,
-    as_naive_date,
-    datatypes::Date32Type::from_naive_date
-);
+impl_primitive_from_variant!(datatypes::Date32Type, as_naive_date, |v| {
+    Some(datatypes::Date32Type::from_naive_date(v))
+});
+impl_primitive_from_variant!(datatypes::Date64Type, as_naive_date, |v| {
+    Some(datatypes::Date64Type::from_naive_date(v))
+});
+impl_primitive_from_variant!(datatypes::Time32SecondType, as_time_utc, |v| {
+    // Return None if there are leftover nanoseconds
+    if v.nanosecond() != 0 {
+        None
+    } else {
+        Some(v.num_seconds_from_midnight() as i32)
+    }
+});
+impl_primitive_from_variant!(datatypes::Time32MillisecondType, as_time_utc, 
|v| {
+    // Return None if there are leftover microseconds
+    if v.nanosecond() % 1_000_000 != 0 {
+        None
+    } else {
+        Some((v.num_seconds_from_midnight() * 1_000) as i32 + (v.nanosecond() 
/ 1_000_000) as i32)
+    }
+});
 impl_primitive_from_variant!(datatypes::Time64MicrosecondType, as_time_utc, 
|v| {
-    (v.num_seconds_from_midnight() * 1_000_000 + v.nanosecond() / 1_000) as i64
+    Some((v.num_seconds_from_midnight() * 1_000_000 + v.nanosecond() / 1_000) 
as i64)

Review Comment:
   We don't need to handle the case `v.nanosecond() % 1000 != 0` here. Thanks 
for `variant_array::canonicalize_and_verify_data_type`, we can assume that the 
input here is always `Time64(TimeUnit::Microsecond)`(No `Time32` or 
`Time64(TimeUnitNanosecond)`)



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