sunchao opened a new issue, #7747: URL: https://github.com/apache/datafusion-comet/issues/7747
### Describe the bug In the automated review of #7715 at `28026d13`, andygrove reported that a native Parquet round trip panicked with `Unable to downcast to primitive array` when reading a top-level `Dictionary(Int32, Timestamp(ms))` column as `Timestamp(us)`. The stored value was 7 ms after the Unix epoch. [Reviewer’s reproduction](https://github.com/apache/datafusion-comet/pull/7715#pullrequestreview-6000547282) ### Steps to reproduce 1. Create a one-row Arrow record batch with a single top-level column named `ts`. Give it an `Int32` dictionary key of `0` pointing to a `TimestampMillisecondArray` containing `7`. 2. Pass the batch to the native Parquet schema adapter’s `roundtrip` helper with a required schema that requests `ts` as `Timestamp(Microsecond, None)`. The helper writes the batch to Parquet and reads it back, with the dictionary type recorded in the footer’s `ARROW:schema`. [Round-trip helper](https://github.com/apache/datafusion-comet/blob/f141d9010e89423f5e0387d2e9e1990e3c4b684b/native/core/src/parquet/schema_adapter.rs#L3037-L3047) ### Expected behavior The scan should return one row with `ts` equal to 7,000 µs after the Unix epoch. ### Additional context I traced the reported failure in the source on `main` at `f141d901`. The schema adapter selects the scalar `Cast` for the top-level dictionary. The cast calls `array_with_timezone`, whose dictionary arm accepts any timestamp unit and then downcasts the values to `TimestampMicrosecondType`. At that point the values are still milliseconds, so the downcast fails before unit conversion. [Schema adapter](https://github.com/apache/datafusion-comet/blob/f141d9010e89423f5e0387d2e9e1990e3c4b684b/native/core/src/parquet/schema_adapter.rs#L1483-L1534), [cast](https://github.com/apache/datafusion-comet/blob/f141d9010e89423f5e0387d2e9e1990e3c4b684b/native/spark-expr/src/conversion_funcs/cast.rs#L282), [dictionary downcast](https://github.com/apache/datafusion-comet/blob/f141d9010e89423f5e0387d2e9e1990e3c4b684b/native/spark-expr/src/utils.rs#L152-L161) -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
