wjones127 opened a new issue, #3448:
URL: https://github.com/apache/arrow-rs/issues/3448
**Is your feature request related to a problem or challenge? Please describe
what you are trying to do.**
This is quite verbose:
```rust
let col: Option<ArrayRef> =
record_batch.column(record_batch.schema().column_with_name("my_column"))
```
**Describe the solution you'd like**
The simplest option is to add `column_by_name()` for `RecordBatch`. It is
already implemented for `StructArray`.
```rust
let col: Option<ArrayRef> = record_batch.column_by_name("my_column")
```
But it might also be desirable to implement
[std::ops::Index](https://doc.rust-lang.org/std/ops/trait.Index.html) for
`RecordBatch`:
```rust
let col: Option<ArrayRef> = record_batch["my_column"]
```
**Describe alternatives you've considered**
<!--
A clear and concise description of any alternative solutions or features
you've considered.
-->
**Additional context**
I was working with highly nested schemas with multiple levels of
StructArrays in some unit tests, and it was a little annoying to access those
deep fields. In an ideal world, I might be able to do something along the lines
of:
```rust
let col: Option<ArrayRef> = record_batch["top_level_column"]?
.as_struct_array()?["mid_level_column"]
.as_struct_array()?["inner_column"];
```
This implies `StructArray` would implement `Index` in the same way that
`RecordBatch` does. If we wanted to get fancy, it might not be crazy to
implement this for `ListArray` or even `MapArray`.
--
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]