linzch3 opened a new pull request, #3727:
URL: https://github.com/apache/iceberg-rust/pull/3727

   ## Which issue does this PR close?
   
   - Closes #3723.
   
   ## What changes are included in this PR?
   
   **Background.** A manifest list whose partition summary bound has the wrong 
length for its type (e.g. a 3-byte bound on an int partition field) made scan 
planning panic in `ManifestEvaluator::eval`, even though `eval` already returns 
`Result<bool>`.
   
   **Root cause.** `ManifestFilterVisitor::bytes_to_datum` called `.unwrap()` 
on `Datum::try_from_bytes` (and on `as_primitive_type()`).
   
   **Fix.** `bytes_to_datum` now returns `Result<Datum>`, and the callers (`<`, 
`<=`, `>`, `>=`, `=`, `IN`) propagate the error with `?`. A bad bound gives the 
`DataInvalid` error from `Datum::try_from_bytes`. A non-primitive type there 
also returns `DataInvalid` instead of panicking. Valid manifests are evaluated 
exactly as before.
   
   ## Are these changes tested?
   
   Yes. `test_malformed_bound_returns_error` uses a 3-byte bound on the int 
field, once as the lower bound and once as the upper bound, and checks that 
every operator that decodes that bound returns `ErrorKind::DataInvalid`. It 
panics without the fix.
   
   Ran locally: `cargo test -p iceberg --lib` (2271 passed), `cargo clippy -p 
iceberg --all-targets --all-features -- -D warnings`, `cargo fmt --all -- 
--check`.
   
   **Limitations.**
   - `starts_with` / `not_starts_with` compare raw bytes and never decode, so 
they still don't notice a malformed bound (same as before, no panic there).
   - `inspect/manifests.rs` has a similar `try_from_bytes(..).unwrap()` when 
building the manifests metadata table. I left it out to keep this PR to the 
issue, can fix it here or in a follow-up if u want.
   
   ## AI Disclosure
   
   This change was prepared with an AI coding assistant; the tests above were 
run locally and I've reviewed the changes myself.
   
   Opening as a draft only because I'm at the 3 open non-draft PR limit for 
non-committers. Happy to rework it if u'd prefer a different approach (e.g. 
treating an undecodable bound as "rows might match" instead of an error).
   


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