ShreddedSchemaBuilder

Struct ShreddedSchemaBuilder 

Source
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: VariantSchemaNode

Implementations§

Source§

impl ShreddedSchemaBuilder

Source

pub fn new() -> Self

Create a new empty schema builder.

Source

pub fn with_path<'a, P, F>(self, path: P, field: F) -> Self
where 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 via IntoShreddingField (e.g. FieldRef, &DataType, or (&DataType, bool) to control nullability)
Source

pub fn build(self) -> DataType

Build the final [DataType].

Trait Implementations§

Source§

impl Clone for ShreddedSchemaBuilder

Source§

fn clone(&self) -> ShreddedSchemaBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ShreddedSchemaBuilder

Source§

fn default() -> ShreddedSchemaBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

§

impl<T> Ungil for T
where T: Send,