-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Given the below program
use arrow_array::RecordBatch;
use narrow::{array::StructArray, ArrayType};
#[derive(ArrayType)]
// `String` is just an example; let's say it can be any type that `narrow` supports
struct NewType(String);
impl NewType {
fn new(s: String) -> Self {
Self(s)
}
}
fn main() {
let nt = NewType::new("test".to_string());
let struct_array = vec![nt].into_iter().collect::<StructArray<NewType>>();
let record_batch = RecordBatch::from(struct_array);
println!("{}", &record_batch.schema());
// println!("{:#?}", record_batch);
arrow_cast::pretty::print_batches(&[record_batch]).unwrap();
}and the program's output is
Field { name: "_0", data_type: Utf8, nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} }
+------+
| _0 |
+------+
| test |
+------+
is it possible to add a specialization to narrow-derive/src/struct.rs, such that if it's a struct with just one field, assume it's a NewType (struct w/ unnamed field), and create an ArrayType (serialize) not the struct but the inner field.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels