pub struct StructField {
pub name: String,
pub data_type: DataType,
pub nullable: bool,
pub metadata: HashMap<String, MetadataValue>,
}Fields§
§name: StringName of this (possibly nested) column
data_type: DataTypeThe data type of this field
nullable: boolDenotes 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 create_metadata_column(
name: impl Into<String>,
spec: MetadataColumnSpec,
) -> Self
pub fn create_metadata_column( name: impl Into<String>, spec: MetadataColumnSpec, ) -> Self
Creates a metadata column of the given spec with the given name.
Sourcepub fn default_row_index_column() -> &'static StructField
pub fn default_row_index_column() -> &'static StructField
Returns the default row index metadata column used by Kernel.
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.
Sourcepub fn is_metadata_column(&self) -> bool
pub fn is_metadata_column(&self) -> bool
Returns true if this field is a metadata column.
Sourcepub fn get_metadata_column_spec(&self) -> Option<MetadataColumnSpec>
pub fn get_metadata_column_spec(&self) -> Option<MetadataColumnSpec>
Returns the metadata column spec if this is a metadata column, otherwise returns None.
Sourcepub fn is_internal_column(&self) -> bool
pub fn is_internal_column(&self) -> bool
Returns true if this field is an internal column added by Kernel.
Internal columns must be removed before returning scan results to the user.
Sourcepub fn as_internal_column(self) -> Self
pub fn as_internal_column(self) -> Self
Marks this field as an internal column.
pub fn get_config_value( &self, key: &ColumnMetadataKey, ) -> Option<&MetadataValue>
Sourcepub fn physical_name(&self, column_mapping_mode: ColumnMappingMode) -> &str
Available on crate feature internal-api only.
pub fn physical_name(&self, column_mapping_mode: ColumnMappingMode) -> &str
internal-api only.Get the physical name for this field as it should be read from parquet.
When column_mapping_mode is None, always returns the logical name (even if physical
name metadata is present). When mode is Id or Name, returns the physical name from
metadata if present, otherwise returns the logical name.
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 Display for StructField
impl Display for StructField
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-native-tls or default-engine-rustls or arrow-conversion) only.
impl TryFromArrow<&Field> for StructField
arrow-conversion and (crate features default-engine-native-tls or default-engine-rustls 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-native-tls or default-engine-rustls or arrow-conversion) only.
impl TryFromKernel<&StructField> for Field
arrow-conversion and (crate features default-engine-native-tls or default-engine-rustls 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<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.
Source§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-native-tls or default-engine-rustls 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-native-tls or default-engine-rustls or arrow-conversion) and crate feature arrow-conversion only.