blackmwk commented on code in PR #3632:
URL: https://github.com/apache/iceberg-rust/pull/3632#discussion_r4664399768
##########
crates/iceberg/src/arrow/int96.rs:
##########
@@ -44,66 +50,69 @@ use crate::{Error, ErrorKind};
pub(crate) fn coerce_int96_timestamps(
arrow_schema: &ArrowSchemaRef,
iceberg_schema: &Schema,
-) -> Option<Arc<ArrowSchema>> {
- let mut visitor = Int96CoercionVisitor::new(iceberg_schema);
- let coerced = visit_schema(arrow_schema, &mut visitor).ok()?;
- if visitor.changed {
- Some(Arc::new(coerced))
- } else {
- None
+ parquet_schema: &SchemaDescriptor,
+) -> Result<Option<Arc<ArrowSchema>>> {
+ if !parquet_schema
+ .columns()
+ .iter()
+ .any(|column| column.physical_type() == PhysicalType::INT96)
+ {
+ return Ok(None);
Review Comment:
Leaving INT64 nanoseconds at their physical precision fixes the 1000×
scaling error, but I can still get a silent NULL for #3616. I wrote a file with
embedded field IDs, an integer `id`, and an optional INT64 `TIMESTAMP(NANOS)`
column `ts` containing one second after the epoch. With an Iceberg `timestamp`,
selecting `ts` alone returns 1,000,000 µs. Selecting `ts, id` returns NULL for
the same row. I got the same results with a UTC-adjusted file and Iceberg
`timestamptz`.
The projection check drops the nanosecond field when the table requests
microseconds. Selecting only `ts` happens to trigger the read-all fallback, so
the value reaches the cast. Could we keep the physical type here, allow the
matching timestamp column through projection for conversion, and cover both
selections in a reader test? If the projection fix is deferred, please keep
#3616 open. [Projection check and
fallback](https://github.com/apache/iceberg-rust/blob/ace31f41cc00b3d6dc51404d5a55140bedaee6bb/crates/iceberg/src/arrow/reader/projection.rs#L239-L269)
##########
crates/iceberg/src/arrow/int96.rs:
##########
@@ -44,66 +50,69 @@ use crate::{Error, ErrorKind};
pub(crate) fn coerce_int96_timestamps(
arrow_schema: &ArrowSchemaRef,
iceberg_schema: &Schema,
-) -> Option<Arc<ArrowSchema>> {
- let mut visitor = Int96CoercionVisitor::new(iceberg_schema);
- let coerced = visit_schema(arrow_schema, &mut visitor).ok()?;
- if visitor.changed {
- Some(Arc::new(coerced))
- } else {
- None
+ parquet_schema: &SchemaDescriptor,
+) -> Result<Option<Arc<ArrowSchema>>> {
+ if !parquet_schema
+ .columns()
+ .iter()
+ .any(|column| column.physical_type() == PhysicalType::INT96)
+ {
+ return Ok(None);
}
+ let mut visitor = Int96CoercionVisitor::new(iceberg_schema,
parquet_schema);
+ let coerced = visit_schema(arrow_schema, &mut visitor)?;
Review Comment:
This visits the entire file before projection, so an unselected list can now
prevent an unrelated column from being read. I tested a file with `id = 42`, an
INT96 timestamp, and a Parquet list whose embedded Arrow schema declares
`ListView<Int32>`. Selecting only `id` returns 42 on the PR base and fails here
with `Cannot visit Arrow data type: ListView` on this commit.
Could we teach the traversal to handle list views and consume their element
leaves in file order? That would preserve the leaf-count check and let the `id`
read succeed. An end-to-end test projecting only `id` from this file would
cover the regression.
--
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]