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:
|
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:
|
"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:
https://github.com/apache/parquet-testing/blob/84d525a8731cec345852fb4ea2e7c581fbf2ef29/variant/data_dictionary.json#L46-L54
Additional context
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::fieldwas not implemented: https://github.com/apache/arrow-rs/blob/71ee9d9aa090a4d733c8404c6edb8d34d767a0c4/parquet-variant/src/variant.rs#L317-L316So when I wrote code to access a field from an object
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
Describe alternatives you've considered
arrow-rs/parquet-variant/tests/variant_interop.rs
Lines 95 to 99 in 2f2e705
To retrieve each field and verify its value
The expected answers are here:
https://github.com/apache/parquet-testing/blob/84d525a8731cec345852fb4ea2e7c581fbf2ef29/variant/data_dictionary.json#L46-L54
Additional context