mbutrovich opened a new issue, #3723:
URL: https://github.com/apache/iceberg-rust/issues/3723

   ### Apache Iceberg Rust version
   
   `main` (641f59049)
   
   ### Describe the bug
   
   
[`ManifestFilterVisitor::bytes_to_datum`](https://github.com/apache/iceberg-rust/blob/641f59049e0aefad0c60e19915ecdb54933e002f/crates/iceberg/src/expr/visitors/manifest_evaluator.rs#L472-L475)
 unwraps the result of `Datum::try_from_bytes`. A manifest list whose partition 
summary bound has the wrong length for its type makes scan planning panic 
instead of returning an error.
   
   ### To Reproduce
   
   Add this test to the `test` module in 
`crates/iceberg/src/expr/visitors/manifest_evaluator.rs` and run `cargo test -p 
iceberg --lib repro_malformed_bound_panics`:
   
   ```rust
   #[test]
   fn repro_malformed_bound_panics() {
       let schema = Arc::new(
           Schema::builder()
               .with_fields(vec![
                   NestedField::optional(1, "i", 
Type::Primitive(PrimitiveType::Int)).into(),
               ])
               .build()
               .unwrap(),
       );
       let filter = Reference::new("i")
           .equal_to(Datum::int(10))
           .bind(schema, true)
           .unwrap();
       let manifest_file = ManifestFile {
           manifest_path: "m".to_string(),
           manifest_length: 1,
           partition_spec_id: 0,
           content: ManifestContentType::Data,
           sequence_number: 1,
           min_sequence_number: 1,
           added_snapshot_id: 1,
           added_files_count: None,
           existing_files_count: None,
           deleted_files_count: None,
           added_rows_count: None,
           existing_rows_count: None,
           deleted_rows_count: None,
           // An int bound has 4 bytes.
           partitions: Some(vec![FieldSummary {
               contains_null: false,
               contains_nan: None,
               lower_bound: Some(vec![1, 2, 3].into()),
               upper_bound: Some(Datum::int(20).to_bytes().unwrap()),
           }]),
           key_metadata: None,
           first_row_id: None,
       };
       let _ = ManifestEvaluator::builder(filter).build().eval(&manifest_file);
   }
   ```
   
   It panics:
   
   ```
   panicked at crates/iceberg/src/expr/visitors/manifest_evaluator.rs:474:49:
   called `Result::unwrap()` on an `Err` value: DataInvalid => failed to 
convert byte slice to array
   ```
   
   ### Expected behavior
   
   `ManifestEvaluator::eval` already returns `Result<bool>`, so it should 
return the `DataInvalid` error from `Datum::try_from_bytes`.
   
   ### Willingness to contribute
   
   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