-
Notifications
You must be signed in to change notification settings - Fork 1k
Description
Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I was trying to write some tests for the VariantBuilder from @PinkCrow007 in
However, I found that VariantObject::field was not implemented: https://github.com/apache/arrow-rs/blob/71ee9d9aa090a4d733c8404c6edb8d34d767a0c4/parquet-variant/src/variant.rs#L317-L316
So when I wrote code to access a field from an object
assert_eq!(variant_object.field("first_name"), Variant::from("Jiaying")It panic'd on me
Describe the solution you'd like
Implement the two methods named in this ticket. The code is here:
arrow-rs/parquet-variant/src/variant.rs
Lines 311 to 317 in 2f2e705
| pub fn fields(&self) -> Result<impl Iterator<Item = (&'m str, Variant<'m, 'v>)>, ArrowError> { | |
| todo!(); | |
| #[allow(unreachable_code)] // Just to infer the return type | |
| Ok(vec![].into_iter()) | |
| } | |
| pub fn field(&self, _name: &'m str) -> Result<Variant<'m, 'v>, ArrowError> { | |
| todo!() |
Describe alternatives you've considered
- Implement the code
- Update the existing tests here:
arrow-rs/parquet-variant/tests/variant_interop.rs
Lines 95 to 99 in 2f2e705
"object_primitive" => { assert!(matches!(variant, Variant::Object(_))); assert_eq!(metadata.dictionary_size(), 7); let dict_val = metadata.get_field_by(0)?; assert_eq!(dict_val, "int_field");
To retrieve each field and verify its value
The expected answers are here:
Additional context