polars_arrow/legacy/
conversion.rsuse crate::array::{ArrayRef, PrimitiveArray, StructArray};
use crate::datatypes::{ArrowDataType, Field};
use crate::record_batch::RecordBatchT;
use crate::types::NativeType;
pub fn chunk_to_struct(chunk: RecordBatchT<ArrayRef>, fields: Vec<Field>) -> StructArray {
let dtype = ArrowDataType::Struct(fields);
StructArray::new(dtype, chunk.len(), chunk.into_arrays(), None)
}
pub fn primitive_to_vec<T: NativeType>(arr: ArrayRef) -> Option<Vec<T>> {
let arr_ref = arr.as_any().downcast_ref::<PrimitiveArray<T>>().unwrap();
let buffer = arr_ref.values().clone();
drop(arr); buffer.into_mut().right()
}