wjones127 opened a new issue, #3764:
URL: https://github.com/apache/arrow-rs/issues/3764

   **Is your feature request related to a problem or challenge? Please describe 
what you are trying to do.**
   
   I wanted to write some code that was generic over `StructArray` and 
`RecordBatch`, but it appears they don't have the same traits (although they 
are easily convertible).
   
   It seems like there are many shared methods that could be brought into a 
common trait:
   
    * `column()`
    * `column_by_name()`
    * `columns()`
    * `num_columns()`
    * `num_rows()`
   
   **Describe the solution you'd like**
   
   I'd propose a trait `ArrowTabular` that has these methods.
   
   **Describe alternatives you've considered**
   
   I'm open to alternatives, but couldn't think of any. In any case, I'm 
implementing a trait for my own use case and if folks are open to this I could 
upstream it into arrow-rs.
   
   **Additional context**
   
   For context, the thing I am trying to implement is:
   
   ```rust
   /// Represents a row in an [ArrowTabular].
   #[derive(Debug, Clone, Copy)]
   struct RowReference<'a, T: ArrowTabular + 'a> {
       pub inner: &'a T,
       pub pos: usize
   }
   
   impl<'a, T: ArrowTabular + 'a> RowReference<'a, T> {
       fn get_str(&'a self, col_i: usize) -> Option<&'a str> {
           let column = as_string_array(self.inner.column(col_i));
           if column.is_null(self.pos) {
               None
           } else {
               Some(column.value(self.pos))
           }
       }
   }
   ```
   
   This is to help navigate the highly nested schema in [ADBC's GetObjects 
output](https://github.com/apache/arrow-adbc/blob/e79edafdb02339664ea735097f8c1edc0ea052de/adbc.h#L815),
 where an entry might be a row of a record batch or a row in a struct array, 
depending on which level you are at.


-- 
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]

Reply via email to