pub fn to_arrow2<T: Serialize>(
fields: &[Field],
items: T,
) -> Result<Vec<Box<dyn Array>>>Expand description
Build arrow2 arrays from the given items (requires one of the arrow2-*
features)
items should be given in the form a list of records (e.g., a vector of
structs). To serialize items encoding single values consider the
Items wrapper.
To build arrays record by record use ArrayBuilder.
use arrow2::datatypes::Field;
use serde::{Serialize, Deserialize};
use serde_arrow::schema::{SchemaLike, TracingOptions};
#[derive(Serialize, Deserialize)]
struct Record {
a: Option<f32>,
b: u64,
}
let items = vec![
Record { a: Some(1.0), b: 2},
// ...
];
let fields = Vec::<Field>::from_type::<Record>(TracingOptions::default())?;
let arrays = serde_arrow::to_arrow2(&fields, &items)?;