MCPcopy Create free account
hub / github.com/apache/arrow-rs / downcast_array

Function downcast_array

arrow-array/src/cast.rs:814–819  ·  view source on GitHub ↗

Downcasts a `dyn Array` to a concrete type ``` # use arrow_array::{BooleanArray, Int32Array, RecordBatch, StringArray}; # use arrow_array::cast::downcast_array; struct ConcreteBatch { col1: Int32Array, col2: BooleanArray, col3: StringArray, } impl ConcreteBatch { fn new(batch: &RecordBatch) -> Self { Self { col1: downcast_array(batch.column(0).as_ref()), col2: downcast_array(batch.column(1).as_r

(array: &dyn Array)

Source from the content-addressed store, hash-verified

812///
813/// Panics if array is not of the correct data type
814pub fn downcast_array<T>(array: &dyn Array) -> T
815where
816 T: From<ArrayData>,
817{
818 T::from(array.to_data())
819}
820
821mod private {
822 pub trait Sealed {}

Callers 3

test_into_builderFunction · 0.85
test_downcast_arrayFunction · 0.85

Calls 1

to_dataMethod · 0.45

Tested by 3

test_into_builderFunction · 0.68
test_downcast_arrayFunction · 0.68