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§
Source§impl ShreddedSchemaBuilder
impl ShreddedSchemaBuilder
Sourcepub fn with_path<'a, P, F>(self, path: P, field: F) -> Selfwhere
P: Into<VariantPath<'a>>,
F: IntoShreddingField,
pub fn with_path<'a, P, F>(self, path: P, field: F) -> Selfwhere
P: Into<VariantPath<'a>>,
F: IntoShreddingField,
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 to [VariantPath] (e.g., a&str)field- Anything convertible viaIntoShreddingField(e.g.FieldRef,&DataType, or(&DataType, bool)to control nullability)
Trait Implementations§
Source§impl Clone for ShreddedSchemaBuilder
impl Clone for ShreddedSchemaBuilder
Source§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 moreSource§impl Default for ShreddedSchemaBuilder
impl Default for ShreddedSchemaBuilder
Source§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