comphead commented on code in PR #3540:
URL: https://github.com/apache/iceberg-rust/pull/3540#discussion_r4657240053


##########
crates/iceberg/src/arrow/reader/row_filter.rs:
##########
@@ -220,6 +239,33 @@ impl ArrowReader {
     }
 }
 
+/// The top-level fields holding `leaf_ids`, pruned to those leaves, and their 
ids in leaf order
+/// (the filter batch's column order). Only these fields are converted, so the 
transformer's
+/// per-file setup does not grow with the table's width.
+fn filter_schema(snapshot_schema: &Schema, leaf_ids: &[i32]) -> 
Result<(Schema, Vec<i32>)> {
+    let mut roots: Vec<NestedFieldRef> = Vec::with_capacity(leaf_ids.len());
+    for accessor in leaf_ids
+        .iter()
+        .filter_map(|id| snapshot_schema.accessor_by_field_id(*id))

Review Comment:
   Agreed, fixed in 87900740d. A leaf reaches `filter_schema` only if both the 
predicate and the file have it, and the scan binds predicates and equality 
deletes to the task schema. So only a task built outside `TableScan`, with a 
predicate bound to another schema, gets here. For that task, skipping the leaf 
left the filter batch with fewer columns than the predicate's positions. With 
row-group filtering off, the read panicked with `index out of bounds: the len 
is 0 but the index is 0`. With default options, the row-group evaluator already 
rejects the task with "Could not find a field with id '1' in the snapshot 
schema". `filter_schema` now fails with `DataInvalid` in both cases, worded 
like `validate_equality_ids` for equality deletes, and 
`test_filter_schema_prunes_nested_roots` covers it.
   



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