pub struct Schema {
pub schema_id: i32,
pub fields: Vec<Field>,
pub identifier_field_ids: Vec<i32>,
}Expand description
A schema defines the structure of records in a table.
Schemas are immutable once created. Schema evolution is achieved by creating new schemas and updating the table’s current schema reference.
§Example
use supercore::schema::{Schema, Field, Type};
let schema = Schema::builder(0)
.with_field(1, "id", Type::Long, true)
.with_field(2, "name", Type::String, true)
.with_field(3, "email", Type::String, false)
.build();Fields§
§schema_id: i32Unique identifier for this schema version.
fields: Vec<Field>The list of fields in this schema.
identifier_field_ids: Vec<i32>Optional identifier field IDs (for tables with primary keys).
Implementations§
Source§impl Schema
impl Schema
Sourcepub fn to_arrow_schema(&self) -> Schema
pub fn to_arrow_schema(&self) -> Schema
Converts this schema to an Arrow schema.
Sourcepub fn to_arrow_schema_ref(&self) -> SchemaRef
pub fn to_arrow_schema_ref(&self) -> SchemaRef
Converts this schema to an Arrow SchemaRef.
Sourcepub fn to_df_schema(&self) -> Result<DFSchema>
pub fn to_df_schema(&self) -> Result<DFSchema>
Converts this schema to a DataFusion DFSchema.
Sourcepub fn builder(schema_id: i32) -> SchemaBuilder
pub fn builder(schema_id: i32) -> SchemaBuilder
Creates a new schema builder.
Sourcepub fn find_field(&self, field_id: i32) -> Option<&Field>
pub fn find_field(&self, field_id: i32) -> Option<&Field>
Finds a field by its ID.
Sourcepub fn find_field_by_name(&self, name: &str) -> Option<&Field>
pub fn find_field_by_name(&self, name: &str) -> Option<&Field>
Finds a field by its name.
Sourcepub fn highest_field_id(&self) -> i32
pub fn highest_field_id(&self) -> i32
Returns the highest field ID in this schema.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnwindSafe for Schema
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