pub struct StructType { /* private fields */ }Expand description
The deltalake crate is currently just a meta-package shim for deltalake-core A struct is used to represent both the top-level schema of the table as well as struct columns that contain nested columns.
Implementations§
Source§impl StructType
impl StructType
Sourcepub fn try_new(
fields: impl IntoIterator<Item = StructField>,
) -> Result<StructType, Error>
pub fn try_new( fields: impl IntoIterator<Item = StructField>, ) -> Result<StructType, Error>
Creates a new StructType from the given fields.
Returns an error if:
- the schema contains duplicate field names
- the schema contains duplicate metadata columns
- the schema contains nested metadata columns
Sourcepub fn try_from_results<E>(
fields: impl IntoIterator<Item = Result<StructField, E>>,
) -> Result<StructType, Error>
pub fn try_from_results<E>( fields: impl IntoIterator<Item = Result<StructField, E>>, ) -> Result<StructType, Error>
Creates a new StructType from a fallible iterator of fields.
This constructor collects all fields from the iterator, returning the first error
encountered, or a new StructType if all fields are successfully collected and validated.
pub fn builder() -> StructTypeBuilder
Sourcepub fn new_unchecked(
fields: impl IntoIterator<Item = StructField>,
) -> StructType
pub fn new_unchecked( fields: impl IntoIterator<Item = StructField>, ) -> StructType
Creates a new StructType from the given fields without validating them.
This should only be used when you are sure that the fields are valid.
Refer to StructType::try_new for more details on the validation checks.
Sourcepub fn project_as_struct(
&self,
names: &[impl AsRef<str>],
) -> Result<StructType, Error>
pub fn project_as_struct( &self, names: &[impl AsRef<str>], ) -> Result<StructType, Error>
Gets a StructType containing StructFields of the given names. The order of fields in
the returned schema will match the order passed to this function, which can be different
from this order in this schema. Returns an Err if a specified field doesn’t exist.
Sourcepub fn project(
&self,
names: &[impl AsRef<str>],
) -> Result<Arc<StructType>, Error>
pub fn project( &self, names: &[impl AsRef<str>], ) -> Result<Arc<StructType>, Error>
Gets a SchemaRef containing StructFields of the given names. The order of fields in
the returned schema will match the order passed to this function, which can be different
from this order in this schema. Returns an Err if a specified field doesn’t exist.
Sourcepub fn add(
&self,
fields: impl IntoIterator<Item = StructField>,
) -> Result<StructType, Error>
pub fn add( &self, fields: impl IntoIterator<Item = StructField>, ) -> Result<StructType, Error>
Adds fields to this StructType, returning a new StructType.
Sourcepub fn add_metadata_column(
&self,
name: impl Into<String>,
spec: MetadataColumnSpec,
) -> Result<StructType, Error>
pub fn add_metadata_column( &self, name: impl Into<String>, spec: MetadataColumnSpec, ) -> Result<StructType, Error>
Adds a predefined metadata column to this StructType, returning a new StructType.
Sourcepub fn index_of(&self, name: impl AsRef<str>) -> Option<usize>
pub fn index_of(&self, name: impl AsRef<str>) -> Option<usize>
Returns the index of the field with the given name, or None if not found.
Sourcepub fn index_of_metadata_column(
&self,
spec: &MetadataColumnSpec,
) -> Option<&usize>
pub fn index_of_metadata_column( &self, spec: &MetadataColumnSpec, ) -> Option<&usize>
Returns the index of the metadata column with the given spec, or None if not found.
Sourcepub fn contains(&self, name: impl AsRef<str>) -> bool
pub fn contains(&self, name: impl AsRef<str>) -> bool
Checks if the StructType contains a field with the specified name.
Sourcepub fn contains_metadata_column(&self, spec: &MetadataColumnSpec) -> bool
pub fn contains_metadata_column(&self, spec: &MetadataColumnSpec) -> bool
Checks if the StructType contains a metadata column with the given spec.
Sourcepub fn field(&self, name: impl AsRef<str>) -> Option<&StructField>
pub fn field(&self, name: impl AsRef<str>) -> Option<&StructField>
Gets the field with the given name.
Sourcepub fn field_with_index(
&self,
name: impl AsRef<str>,
) -> Option<(usize, &StructField)>
pub fn field_with_index( &self, name: impl AsRef<str>, ) -> Option<(usize, &StructField)>
Gets the field with the given name and its index.
Sourcepub fn field_at_index(&self, index: usize) -> Option<&StructField>
pub fn field_at_index(&self, index: usize) -> Option<&StructField>
Gets the field at the given index.
Sourcepub fn fields(
&self,
) -> impl ExactSizeIterator + DoubleEndedIterator + FusedIterator
pub fn fields( &self, ) -> impl ExactSizeIterator + DoubleEndedIterator + FusedIterator
Gets a reference to all the fields in this struct type.
Sourcepub fn into_fields(
self,
) -> impl ExactSizeIterator + DoubleEndedIterator + FusedIterator
pub fn into_fields( self, ) -> impl ExactSizeIterator + DoubleEndedIterator + FusedIterator
Gets an iterator over all the fields in this struct type.
Sourcepub fn field_names(&self) -> impl ExactSizeIterator
pub fn field_names(&self) -> impl ExactSizeIterator
Gets all the field names in this struct type in the order they are defined.
Sourcepub fn num_fields(&self) -> usize
pub fn num_fields(&self) -> usize
Gets the number of fields in this struct type.
Sourcepub fn metadata_column(&self, spec: &MetadataColumnSpec) -> Option<&StructField>
pub fn metadata_column(&self, spec: &MetadataColumnSpec) -> Option<&StructField>
Gets a reference to the metadata column with the given spec.
Sourcepub fn metadata_columns(&self) -> impl Iterator<Item = &StructField>
pub fn metadata_columns(&self) -> impl Iterator<Item = &StructField>
Gets an iterator over all the metadata columns in this struct type.
Sourcepub fn leaves<'s>(
&self,
own_name: impl Into<Option<&'s str>>,
) -> ColumnNamesAndTypes
pub fn leaves<'s>( &self, own_name: impl Into<Option<&'s str>>, ) -> ColumnNamesAndTypes
Extracts the name and type of all leaf columns, in schema order. Caller should pass Some
own_name if this schema is embedded in a larger struct (e.g. add.*) and None if the
schema is a top-level result (e.g. *).
NOTE: This method only traverses through StructType fields; MapType and ArrayType
fields are considered leaves even if they contain StructType entries/elements.
Sourcepub fn make_physical(
&self,
column_mapping_mode: ColumnMappingMode,
) -> StructType
pub fn make_physical( &self, column_mapping_mode: ColumnMappingMode, ) -> StructType
Applies physical name mappings to this field. If the column_mapping_mode is
ColumnMappingMode::Id, then each StructField will have its parquet field id in the
ColumnMetadataKey::ParquetFieldId metadata field.
NOTE: Caller affirms that the schema was already validated by
crate::table_features::validate_schema_column_mapping, to ensure that annotations are
always and only present when column mapping mode is enabled.
Trait Implementations§
Source§impl Clone for StructType
impl Clone for StructType
Source§fn clone(&self) -> StructType
fn clone(&self) -> StructType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StructType
impl Debug for StructType
Source§impl<'de> Deserialize<'de> for StructType
impl<'de> Deserialize<'de> for StructType
Source§fn deserialize<D>(
deserializer: D,
) -> Result<StructType, <D as Deserializer<'de>>::Error>
fn deserialize<D>( deserializer: D, ) -> Result<StructType, <D as Deserializer<'de>>::Error>
Source§impl Display for StructType
impl Display for StructType
Source§impl From<StructType> for DataType
impl From<StructType> for DataType
Source§fn from(struct_type: StructType) -> DataType
fn from(struct_type: StructType) -> DataType
Source§impl<'a> IntoIterator for &'a StructType
impl<'a> IntoIterator for &'a StructType
Source§type Item = &'a StructField
type Item = &'a StructField
Source§type IntoIter = StructFieldRefIter<'a>
type IntoIter = StructFieldRefIter<'a>
Source§fn into_iter(self) -> <&'a StructType as IntoIterator>::IntoIter
fn into_iter(self) -> <&'a StructType as IntoIterator>::IntoIter
Source§impl IntoIterator for StructType
impl IntoIterator for StructType
Source§type Item = StructField
type Item = StructField
Source§type IntoIter = StructFieldIntoIter
type IntoIter = StructFieldIntoIter
Source§fn into_iter(self) -> <StructType as IntoIterator>::IntoIter
fn into_iter(self) -> <StructType as IntoIterator>::IntoIter
Source§impl PartialEq for StructType
impl PartialEq for StructType
Source§impl Serialize for StructType
impl Serialize for StructType
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl StructTypeExt for StructType
impl StructTypeExt for StructType
Source§fn get_generated_columns(&self) -> Result<Vec<GeneratedColumn>, Error>
fn get_generated_columns(&self) -> Result<Vec<GeneratedColumn>, Error>
Get all get_generated_columns in the schemas
Source§impl TryFromArrow<&Schema> for StructType
impl TryFromArrow<&Schema> for StructType
fn try_from_arrow(arrow_schema: &Schema) -> Result<StructType, ArrowError>
Source§impl TryFromArrow<Arc<Schema>> for StructType
impl TryFromArrow<Arc<Schema>> for StructType
fn try_from_arrow(arrow_schema: Arc<Schema>) -> Result<StructType, ArrowError>
Source§impl TryFromKernel<&StructType> for Schema
impl TryFromKernel<&StructType> for Schema
fn try_from_kernel(s: &StructType) -> Result<Schema, ArrowError>
impl Eq for StructType
impl StructuralPartialEq for StructType
Auto Trait Implementations§
impl Freeze for StructType
impl RefUnwindSafe for StructType
impl Send for StructType
impl Sync for StructType
impl Unpin for StructType
impl UnwindSafe for StructType
Blanket Implementations§
Source§impl<T> AsAny for T
impl<T> AsAny for T
Source§fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
fn any_ref(&self) -> &(dyn Any + Sync + Send + 'static)
dyn Any reference to the object: Read moreSource§fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
fn as_any(self: Arc<T>) -> Arc<dyn Any + Sync + Send>
Arc<dyn Any> reference to the object: Read moreSource§fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
fn into_any(self: Box<T>) -> Box<dyn Any + Sync + Send>
Box<dyn Any>: Read moreSource§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
std::any::type_name, since Any does not provide it and
Any::type_id is useless as a debugging aid (its Debug is just a mess of hex digits).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> DynPartialEq for T
impl<T> DynPartialEq for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.