use arrow_schema::{DataType, Field};
use rustsim_io::arrow::{schema_from_fields, ArrowBatchBuilder, ArrowValue};
#[test]
fn builds_record_batch_from_rows() {
let schema = schema_from_fields(vec![
Field::new("id", DataType::Int64, false),
Field::new("speed", DataType::Float64, false),
Field::new("label", DataType::Utf8, false),
]);
let mut builder = ArrowBatchBuilder::new(schema).expect("builder");
builder
.push_row(&[
ArrowValue::Int64(1),
ArrowValue::Float64(1.5),
ArrowValue::Utf8("a".to_string()),
])
.expect("row 1");
builder
.push_row(&[
ArrowValue::Int64(2),
ArrowValue::Float64(2.5),
ArrowValue::Utf8("b".to_string()),
])
.expect("row 2");
let batch = builder.finish().expect("batch");
assert_eq!(batch.num_rows(), 2);
assert_eq!(batch.num_columns(), 3);
}