pub struct TableSchemaBuilder { /* private fields */ }Expand description
Builder for TableSchema.
The file schema is the only required input; partition columns and virtual
columns are optional. Unlike calling TableSchema’s setters repeatedly,
the builder computes the concatenated table schema exactly once, in
TableSchemaBuilder::build.
let table_schema = TableSchemaBuilder::new(file_schema)
.with_table_partition_cols(vec![Arc::new(Field::new("date", DataType::Utf8, false))])
.build();
assert_eq!(table_schema.table_partition_cols().len(), 1);Implementations§
Source§impl TableSchemaBuilder
impl TableSchemaBuilder
Sourcepub fn new(file_schema: SchemaRef) -> Self
pub fn new(file_schema: SchemaRef) -> Self
Create a builder for a TableSchema over the given file schema, with no
partition or virtual columns yet.
Sourcepub fn with_table_partition_cols(
self,
table_partition_cols: impl Into<Fields>,
) -> Self
pub fn with_table_partition_cols( self, table_partition_cols: impl Into<Fields>, ) -> Self
Set the partition columns, replacing any previously set.
Accepts anything convertible into Fields (e.g. Vec<FieldRef> or an
existing schema’s Fields, which is shared zero-copy).
Sourcepub fn with_virtual_columns(self, virtual_columns: impl Into<Fields>) -> Self
pub fn with_virtual_columns(self, virtual_columns: impl Into<Fields>) -> Self
Set the virtual columns, replacing any previously set.
Virtual columns are produced by the file reader (e.g. Parquet
row_number) and appended at the end of the table schema. Each field
must carry an arrow virtual extension type so the reader can recognize
it.
Accepts anything convertible into Fields (e.g. Vec<FieldRef>).
Sourcepub fn build(self) -> TableSchema
pub fn build(self) -> TableSchema
Build the TableSchema, computing the full
file + partition + virtual schema once.
Trait Implementations§
Source§impl Clone for TableSchemaBuilder
impl Clone for TableSchemaBuilder
Source§fn clone(&self) -> TableSchemaBuilder
fn clone(&self) -> TableSchemaBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TableSchemaBuilder
impl Debug for TableSchemaBuilder
Auto Trait Implementations§
impl Freeze for TableSchemaBuilder
impl RefUnwindSafe for TableSchemaBuilder
impl Send for TableSchemaBuilder
impl Sync for TableSchemaBuilder
impl Unpin for TableSchemaBuilder
impl UnsafeUnpin for TableSchemaBuilder
impl UnwindSafe for TableSchemaBuilder
Blanket Implementations§
impl<T> Allocation for T
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
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> ⓘ
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> ⓘ
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