scovich commented on code in PR #8401: URL: https://github.com/apache/arrow-rs/pull/8401#discussion_r2376376590
########## 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: > Using `panic` here because this value is located in `typed_value` of the `Variant`, and from the spec of `Variant`, there are only `Micro` and `Nano` units for `Timestamp`(with/without timezone), I assumed that this is an error(this could not happen?) Good point! There are definitely variant integration tests (parquet/tests/variant_integration.rs) that assert non-variant types in typed_value columns are an error (cases 127 and 137, specifically). So we should _not_ widen on the read path, but rather reject. Widening would seem to make sense on the shredding write path, tho? -- 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