friendlymatthew commented on code in PR #7757: URL: https://github.com/apache/arrow-rs/pull/7757#discussion_r2167243364
########## 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: I used `.expect` but I agree with @scovich's comments about the err case being basically unreachable. But I imagine this code will change with https://github.com/apache/arrow-rs/issues/7711 ########## 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: I used `expect` and I agree with @scovich's comments about the err case being basically unreachable. But I imagine this code will change with https://github.com/apache/arrow-rs/issues/7711 -- 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: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org