arrow_array::cast

Function downcast_array

Source
pub fn downcast_array<T>(array: &dyn Array) -> T
where T: From<ArrayData>,
Expand description

Downcasts a dyn Array to a concrete type

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_ref()),
            col3: downcast_array(batch.column(2).as_ref()),
        }
    }
}

ยงPanics

Panics if array is not of the correct data type