pub struct StructField {
pub name: String,
pub data_type: DataType,
pub nullable: bool,
pub metadata: HashMap<String, MetadataValue>,
}
Fields§
§name: String
Name of this (possibly nested) column
data_type: DataType
The data type of this field
nullable: bool
Denotes whether this Field can be null
metadata: HashMap<String, MetadataValue>
A JSON map containing information about this column
Implementations§
Source§impl StructField
impl StructField
Sourcepub fn new(
name: impl Into<String>,
data_type: impl Into<DataType>,
nullable: bool,
) -> Self
pub fn new( name: impl Into<String>, data_type: impl Into<DataType>, nullable: bool, ) -> Self
Creates a new field
Sourcepub fn nullable(name: impl Into<String>, data_type: impl Into<DataType>) -> Self
pub fn nullable(name: impl Into<String>, data_type: impl Into<DataType>) -> Self
Creates a new nullable field
Sourcepub fn not_null(name: impl Into<String>, data_type: impl Into<DataType>) -> Self
pub fn not_null(name: impl Into<String>, data_type: impl Into<DataType>) -> Self
Creates a new non-nullable field
Sourcepub fn with_metadata(
self,
metadata: impl IntoIterator<Item = (impl Into<String>, impl Into<MetadataValue>)>,
) -> Self
pub fn with_metadata( self, metadata: impl IntoIterator<Item = (impl Into<String>, impl Into<MetadataValue>)>, ) -> Self
Replaces self.metadata
with the list of <key, value> pairs in metadata
.
Sourcepub fn add_metadata(
self,
metadata: impl IntoIterator<Item = (impl Into<String>, impl Into<MetadataValue>)>,
) -> Self
pub fn add_metadata( self, metadata: impl IntoIterator<Item = (impl Into<String>, impl Into<MetadataValue>)>, ) -> Self
Extends self.metadata
to include the <key, value> pairs in metadata
.
pub fn get_config_value( &self, key: &ColumnMetadataKey, ) -> Option<&MetadataValue>
Sourcepub fn physical_name(&self) -> &str
pub fn physical_name(&self) -> &str
Get the physical name for this field as it should be read from parquet.
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.
Sourcepub fn with_name(&self, new_name: impl Into<String>) -> Self
pub fn with_name(&self, new_name: impl Into<String>) -> Self
Change the name of a field. The field will preserve its data type and nullability. Note that this allocates a new field.
pub fn name(&self) -> &String
pub fn is_nullable(&self) -> bool
pub const fn data_type(&self) -> &DataType
pub const fn metadata(&self) -> &HashMap<String, MetadataValue>
Sourcepub fn metadata_with_string_values(&self) -> HashMap<String, String>
pub fn metadata_with_string_values(&self) -> HashMap<String, String>
Convert our metadata into a HashMap<String, String>. Note this copies all the data so can be expensive for large metadata
Sourcepub fn make_physical(&self, column_mapping_mode: ColumnMappingMode) -> Self
Available on crate feature internal-api
only.
pub fn make_physical(&self, column_mapping_mode: ColumnMappingMode) -> Self
internal-api
only.Applies physical name and field ID mappings to this field.
This function sets the field ID for the physical StructField
only if the
column_mapping_mode
is Id
. The field ID is specified using the
ColumnMetadataKey::ParquetFieldId
metadata field. Readers should use
ColumnMetadataKey::ParquetFieldId
to match fields to the Parquet schema.
If a physical StructField contains a field ID, the reader must resolve columns
with that ID. Otherwise, the physical StructField’s name is used. For details,
see read_parquet_files
.
This function also sets the physical name of a field. If column_mapping_mode
is
Id
or Name
, this is specified in ColumnMetadataKey::ColumnMappingPhysicalName
.
Otherwise, the field’s logical name is used.
If the column_mapping_mode
is None
, then all column mapping metadata is removed.
If the column_mapping_mode
is Name
, then all Id mode column mapping metadata is
removed.
NOTE: The caller must ensure that the schema has been validated by
crate::table_features::validate_schema_column_mapping
to ensure that annotations are
present only when column mapping mode is enabled.
Trait Implementations§
Source§impl Clone for StructField
impl Clone for StructField
Source§fn clone(&self) -> StructField
fn clone(&self) -> StructField
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for StructField
impl Debug for StructField
Source§impl<'de> Deserialize<'de> for StructField
impl<'de> Deserialize<'de> for StructField
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>,
Source§impl PartialEq for StructField
impl PartialEq for StructField
Source§impl Serialize for StructField
impl Serialize for StructField
Source§impl TryFromArrow<&Field> for StructField
Available on crate feature arrow-conversion
and (crate features default-engine
or arrow-conversion
) only.
impl TryFromArrow<&Field> for StructField
arrow-conversion
and (crate features default-engine
or arrow-conversion
) only.fn try_from_arrow(arrow_field: &ArrowField) -> Result<Self, ArrowError>
Source§impl TryFromKernel<&StructField> for Field
Available on crate feature arrow-conversion
and (crate features default-engine
or arrow-conversion
) only.
impl TryFromKernel<&StructField> for Field
arrow-conversion
and (crate features default-engine
or arrow-conversion
) only.fn try_from_kernel(f: &StructField) -> Result<Self, ArrowError>
impl Eq for StructField
impl StructuralPartialEq for StructField
Auto Trait Implementations§
impl Freeze for StructField
impl RefUnwindSafe for StructField
impl Send for StructField
impl Sync for StructField
impl Unpin for StructField
impl UnwindSafe for StructField
Blanket Implementations§
Source§impl<T> AsAny for T
impl<T> AsAny for T
Source§fn any_ref(&self) -> &(dyn Any + Send + Sync + 'static)
fn any_ref(&self) -> &(dyn Any + Send + Sync + 'static)
dyn Any
reference to the object: Read moreSource§fn as_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
fn as_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
Arc<dyn Any>
reference to the object: Read moreSource§fn into_any(self: Box<T>) -> Box<dyn Any + Send + Sync>
fn into_any(self: Box<T>) -> Box<dyn Any + Send + Sync>
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelTypewhere
ArrowType: TryFromKernel<KernelType>,
impl<KernelType, ArrowType> TryIntoArrow<ArrowType> for KernelTypewhere
ArrowType: TryFromKernel<KernelType>,
Source§fn try_into_arrow(self) -> Result<ArrowType, ArrowError>
fn try_into_arrow(self) -> Result<ArrowType, ArrowError>
default-engine
or arrow-conversion
) and crate feature arrow-conversion
only.Source§impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowTypewhere
KernelType: TryFromArrow<ArrowType>,
impl<KernelType, ArrowType> TryIntoKernel<KernelType> for ArrowTypewhere
KernelType: TryFromArrow<ArrowType>,
Source§fn try_into_kernel(self) -> Result<KernelType, ArrowError>
fn try_into_kernel(self) -> Result<KernelType, ArrowError>
default-engine
or arrow-conversion
) and crate feature arrow-conversion
only.