g0itb4 opened a new issue, #4467:
URL: https://github.com/apache/iceberg-python/issues/4467

   ### Apache Iceberg version
   
   main (ee86b4b), also 0.12.0
   
   ### Please describe the bug
   
   Reading a v3 table with `scan().to_arrow()` fails when:
   
   1. some data files were written before an optional `timestamptz_ns` column 
was added, and
   2. the files that have the column were written by a writer that labels UTC 
as `+00:00` in the
      embedded Arrow schema (iceberg-rust 0.11 does this for `timestamptz` and 
`timestamptz_ns`).
   
   ```
   pyarrow.lib.ArrowTypeError: Unable to merge: Field _archived_at has 
incompatible types:
   timestamp[ns, tz=UTC] vs timestamp[ns, tz=+00:00]: Cannot merge timestamps 
with differing timezones
   ```
   
   Files without the column get a null column typed from the table schema 
(`timestamp[ns, tz=UTC]`).
   Files with the column keep the type from the file (`timestamp[ns, 
tz=+00:00]`), because
   `ArrowProjectionVisitor._cast_if_needed` has a branch that relabels UTC 
aliases for `TimestamptzType`
   but none for `TimestamptzNanoType`. `pa.concat_tables` then refuses the two 
labels.
   
   `UTC_ALIASES` already lists `+00:00`, so the microsecond type is handled; 
only the nanosecond type
   is not.
   
   Reproduction without another writer: `_to_requested_schema` on a batch whose 
`timestamptz_ns`
   column is `pa.timestamp("ns", tz="+00:00")` returns it unchanged, and 
concatenating it with a
   projection of a file that lacks the column raises the error above.
   
   ### Willingness to contribute
   
   - [x] I can contribute a fix for this bug independently
   


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

Reply via email to