I see what you mean. I was thinking that the function signature would have to be something like this:
trait Array<T> { > fn value(&self) -> T > } Where T would have to implement another trait, call it ValueTrait, in order to define how to extract the different values types, e.g. &str, u32, etc. But as you said, the access to that singular value would be slower (especially if you want to get multiple values) than downcasting the whole column to access the values. I will keep looking at DataFusion to understand how a column is downcasted automatically based on a RecordBatch schema Thanks, On Wed, Jan 27, 2021 at 11:03 PM Andrew Lamb <al...@influxdata.com> wrote: > I think the idea is enticing, but it comes with some challenges: > > 1. Rust is strongly typed so when extracting values we would likely need a > `Scalar` type enum or multiple different `value_bool`, `value_u64` type > functions > 2. Such access would likely be much slower (though possible more > convenient) as it would dispatch based on type for each row (whereas the > downcast_as pattern does that dispatch once per array) > > Andrew > > On Wed, Jan 27, 2021 at 6:27 AM Fernando Herrera < > fernando.j.herr...@gmail.com> wrote: > > > Hi, > > > > I'm wondering if it has been considered to move the value function that > is > > implemented in all the arrays (StringArray, BooleanArray, ListArray, etc) > > as part of the Array trait? > > > > This would help when extracting values from generic arrays that implement > > dyn Array without having to manually downcast the array all the time to > > read a value from the array. > > > > Thanks, > > >