-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib.rs
35 lines (29 loc) · 877 Bytes
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
mod array;
mod cast;
#[cfg(feature = "json")]
pub mod json;
mod utils;
pub use array::VariantArray;
use arrow_schema::{DataType, Field, Fields};
pub use cast::cast_to_variant;
pub const VARIANT_METADATA_FIELD: &str = "metadata";
pub const VARIANT_VALUES_FIELD: &str = "values";
pub fn variant_metadata_type() -> DataType {
// TODO: can we be flexible about this type?
// TODO: should we use REE for this?
DataType::Dictionary(Box::new(DataType::Int8), Box::new(DataType::Binary))
}
pub fn variant_values_type() -> DataType {
// TODO: BinaryView?
DataType::Binary
}
fn variant_fields() -> Fields {
vec![
Field::new(VARIANT_METADATA_FIELD, variant_metadata_type(), false),
Field::new(VARIANT_VALUES_FIELD, variant_values_type(), true),
]
.into()
}
pub fn variant_type() -> DataType {
DataType::Struct(variant_fields())
}