2021-10-21 14:39:29 +00:00
|
|
|
use arrow_util::assert_batches_eq;
|
|
|
|
use mutable_batch::writer::Writer;
|
|
|
|
use mutable_batch::MutableBatch;
|
2022-11-02 18:15:04 +00:00
|
|
|
use schema::Projection;
|
2021-10-21 14:39:29 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_new_column() {
|
|
|
|
let mut batch = MutableBatch::new();
|
|
|
|
let mut writer = Writer::new(&mut batch, 2);
|
|
|
|
|
|
|
|
writer
|
|
|
|
.write_bool("b1", None, vec![true, false].into_iter())
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
writer.commit();
|
|
|
|
|
|
|
|
let expected = &[
|
|
|
|
"+-------+",
|
|
|
|
"| b1 |",
|
|
|
|
"+-------+",
|
|
|
|
"| true |",
|
|
|
|
"| false |",
|
|
|
|
"+-------+",
|
|
|
|
];
|
|
|
|
|
2022-11-02 18:15:04 +00:00
|
|
|
assert_batches_eq!(expected, &[batch.to_arrow(Projection::All).unwrap()]);
|
2021-10-21 14:39:29 +00:00
|
|
|
|
|
|
|
let mut writer = Writer::new(&mut batch, 1);
|
|
|
|
writer
|
|
|
|
.write_string("tag1", None, vec!["v1"].into_iter())
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
std::mem::drop(writer);
|
|
|
|
|
|
|
|
// Should not include tag1 column
|
2022-11-02 18:15:04 +00:00
|
|
|
assert_batches_eq!(expected, &[batch.to_arrow(Projection::All).unwrap()]);
|
2021-10-21 14:39:29 +00:00
|
|
|
}
|