pub struct SchemaBuilder { /* private fields */ }Expand description
Schema Builder for constructing Arrow schemas using a fluent API
§Example
use dbx_core::SchemaBuilder;
use arrow::datatypes::DataType;
let schema = SchemaBuilder::new()
.id("id")
.text("name")
.int32("age").nullable()
.build();Implementations§
Source§impl SchemaBuilder
impl SchemaBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new SchemaBuilder
§Example
use dbx_core::SchemaBuilder;
let builder = SchemaBuilder::new();Sourcepub fn column(self, name: &str, data_type: DataType, nullable: bool) -> Self
pub fn column(self, name: &str, data_type: DataType, nullable: bool) -> Self
Add a column with explicit type and nullability
§Example
use dbx_core::SchemaBuilder;
use arrow::datatypes::DataType;
let schema = SchemaBuilder::new()
.column("id", DataType::Int64, false)
.column("name", DataType::Utf8, true)
.build();Sourcepub fn build(self) -> Schema
pub fn build(self) -> Schema
Build the final Schema
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.id("id")
.text("name")
.build();Sourcepub fn id(self, name: &str) -> Self
pub fn id(self, name: &str) -> Self
Add an ID column (Int64, NOT NULL)
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.id("id")
.build();Sourcepub fn text(self, name: &str) -> Self
pub fn text(self, name: &str) -> Self
Add a text column (Utf8, nullable by default)
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.text("name")
.build();Sourcepub fn int32(self, name: &str) -> Self
pub fn int32(self, name: &str) -> Self
Add an Int32 column (nullable by default)
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.int32("age")
.build();Sourcepub fn int64(self, name: &str) -> Self
pub fn int64(self, name: &str) -> Self
Add an Int64 column (nullable by default)
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.int64("user_id")
.build();Sourcepub fn float64(self, name: &str) -> Self
pub fn float64(self, name: &str) -> Self
Add a Float64 column (nullable by default)
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.float64("salary")
.build();Sourcepub fn boolean(self, name: &str) -> Self
pub fn boolean(self, name: &str) -> Self
Add a Boolean column (nullable by default)
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.boolean("is_active")
.build();Sourcepub fn timestamp(self, name: &str) -> Self
pub fn timestamp(self, name: &str) -> Self
Add a Timestamp column (nullable by default)
§Example
use dbx_core::SchemaBuilder;
let schema = SchemaBuilder::new()
.timestamp("created_at")
.build();Trait Implementations§
Source§impl Clone for SchemaBuilder
impl Clone for SchemaBuilder
Source§fn clone(&self) -> SchemaBuilder
fn clone(&self) -> SchemaBuilder
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 Debug for SchemaBuilder
impl Debug for SchemaBuilder
Auto Trait Implementations§
impl Freeze for SchemaBuilder
impl RefUnwindSafe for SchemaBuilder
impl Send for SchemaBuilder
impl Sync for SchemaBuilder
impl Unpin for SchemaBuilder
impl UnsafeUnpin for SchemaBuilder
impl UnwindSafe for SchemaBuilder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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