askoa commented on issue #3448:
URL: https://github.com/apache/arrow-rs/issues/3448#issuecomment-1371608561

   I don't think we can return Option (or Result) from `std::ops::Index`. The 
trait function `index` returns a reference and hence cannot be a value created 
in the function. The function has to return reference to an item in `self`. 
   
   ```
   pub trait Index<Idx>
   where
       Idx: ?Sized,
   {
       type Output: ?Sized;
   
       fn index(&self, index: Idx) -> &Self::Output;
   }
   ```
   
   So the behavior of `record_batch["name"]` will be similar to 
`record_batch.column(index)`.  
   
   Below are the return types I am planning.  Let me know if you have alternate 
suggestion.
     -  `column_by_name` will return `Option<ArrayRef>` 
     - `column[name]` will return `&ArrayRef`. The function will panic if the 
given name is not in the schema.
   
   


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