Struct ShreddedSchemaBuilder
pub struct ShreddedSchemaBuilder {
root: VariantSchemaNode,
}Expand description
Builder for constructing a variant shredding schema.
The builder pattern makes it easy to incrementally define which fields
should be shredded and with what types. Fields are nullable by default; pass
a (data_type, nullable) pair or a FieldRef to control nullability.
Note: this builder currently only supports struct fields. List support will be added in the future.
§Example
use std::sync::Arc;
use arrow::datatypes::{DataType, Field, TimeUnit};
use parquet_variant::{VariantPath, VariantPathElement};
use parquet_variant_compute::ShreddedSchemaBuilder;
// Define the shredding schema using the builder
let shredding_type = ShreddedSchemaBuilder::default()
// store the "time" field as a separate UTC timestamp
.with_path("time", (&DataType::Timestamp(TimeUnit::Nanosecond, Some("UTC".into())), true))
// store hostname as non-nullable Utf8
.with_path("hostname", (&DataType::Utf8, false))
// pass a FieldRef directly
.with_path(
"metadata.trace_id",
Arc::new(Field::new("trace_id", DataType::FixedSizeBinary(16), false)),
)
// field name with a dot: use VariantPath to avoid splitting
.with_path(
VariantPath::from_iter([VariantPathElement::from("metrics.cpu")]),
&DataType::Float64,
)
.build();
// The shredding_type can now be passed to shred_variant:
// let shredded = shred_variant(&input, &shredding_type)?;Fields§
§root: VariantSchemaNodeImplementations§
§impl ShreddedSchemaBuilder
impl ShreddedSchemaBuilder
pub fn new() -> ShreddedSchemaBuilder
pub fn new() -> ShreddedSchemaBuilder
Create a new empty schema builder.
pub fn with_path<'a, P, F>(self, path: P, field: F) -> ShreddedSchemaBuilder
pub fn with_path<'a, P, F>(self, path: P, field: F) -> ShreddedSchemaBuilder
Insert a typed path into the schema using dot notation (or any
VariantPath convertible).
The path uses dot notation to specify nested fields. For example, “a.b.c” will create a nested structure.
§Arguments
path- Anything convertible toVariantPath(e.g., a&str)field- Anything convertible viaIntoShreddingField(e.g.FieldRef,&DataType, or(&DataType, bool)to control nullability)
pub fn build(self) -> DataType
pub fn build(self) -> DataType
Build the final [DataType].
Trait Implementations§
§impl Clone for ShreddedSchemaBuilder
impl Clone for ShreddedSchemaBuilder
§fn clone(&self) -> ShreddedSchemaBuilder
fn clone(&self) -> ShreddedSchemaBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Default for ShreddedSchemaBuilder
impl Default for ShreddedSchemaBuilder
§fn default() -> ShreddedSchemaBuilder
fn default() -> ShreddedSchemaBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ShreddedSchemaBuilder
impl RefUnwindSafe for ShreddedSchemaBuilder
impl Send for ShreddedSchemaBuilder
impl Sync for ShreddedSchemaBuilder
impl Unpin for ShreddedSchemaBuilder
impl UnwindSafe for ShreddedSchemaBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more