zeroshade commented on issue #10972:
URL: https://github.com/apache/arrow/issues/10972#issuecomment-905161847


   Hey @bidhan-a in order to get the actual value at a given index you need to 
cast the Interface to the correct type which will provide the type-safe access 
methods. One example would be to do a type-switch on the actual `Interface` 
type such as in the integration testing code here: 
https://github.com/apache/arrow/blob/master/go/arrow/internal/arrjson/arrjson.go#L925
   
   Alternately you could switch on the type id:
   
   ```go
   func val(col array.Interface, idx int) interface{} {
       switch col.DataType().ID() {
       case arrow.INT32:
           return col.(*array.Int32).Value(idx)
       case arrow.STRING:
           return col.(*array.String).Value(idx)
       // and so on.....
   }
   ```
   
   Either way, in order to get the value at a given index, you need to know 
which underlying array type you actually have, and all of the types have 
accessors to retrieve the values at indexes once you've type-asserted them to 
the proper type.
   
   Hope that helps!


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