blackmwk commented on code in PR #2301:
URL: https://github.com/apache/iceberg-rust/pull/2301#discussion_r3021031926


##########
crates/iceberg/src/arrow/reader.rs:
##########
@@ -1232,6 +1257,195 @@ fn add_fallback_field_ids_to_arrow_schema(arrow_schema: 
&ArrowSchemaRef) -> Arc<
     ))
 }
 
+/// Coerce Arrow schema types for INT96 columns to match the Iceberg table 
schema.
+///
+/// arrow-rs defaults INT96 to `Timestamp(Nanosecond)`, which overflows i64 
for dates outside
+/// ~1677-2262. We use arrow-rs's schema hint mechanism to read INT96 at the 
resolution
+/// specified by the Iceberg schema (`timestamp` → microsecond, `timestamp_ns` 
→ nanosecond).
+///
+/// Iceberg Java handles this differently: it bypasses parquet-mr with a 
custom column reader
+/// (`GenericParquetReaders.TimestampInt96Reader`). We achieve the same result 
via schema hints.
+///
+/// References:
+/// - Iceberg spec primitive types: 
<https://iceberg.apache.org/spec/#primitive-types>
+/// - arrow-rs schema hint support: 
<https://github.com/apache/arrow-rs/pull/7285>
+fn coerce_int96_timestamps(

Review Comment:
   This is quite hacky. How about we rewrite it with 
ArrowSchemaVisitorWithPartner?



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