alamb commented on code in PR #7757:
URL: https://github.com/apache/arrow-rs/pull/7757#discussion_r2165217535
##########
parquet-variant/src/variant/object.rs:
##########
@@ -145,7 +157,19 @@ impl<'m, 'v> VariantObject<'m, 'v> {
}
/// Get a field's name by index in `0..self.len()`
- pub fn field_name(&self, i: usize) -> Result<&'m str, ArrowError> {
+ pub fn field_name(&self, i: usize) -> Option<&'m str> {
+ if i >= self.num_elements {
+ return None;
+ }
+
+ match self.try_field_name(i) {
+ Ok(field_name) => Some(field_name),
+ Err(err) => panic!("validation error: {}", err),
Review Comment:
maybe `expect` would be cleaner?
```rust
self.try_field_name(i)
.expect("Unexpected validation failure")
```
The `expect` will cause a panic but will include the message and the
underlying error message
--
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]