Struct arrow_schema::Field
source · pub struct Field { /* private fields */ }
Expand description
Implementations§
source§impl Field
impl Field
sourcepub fn new(name: impl Into<String>, data_type: DataType, nullable: bool) -> Self
pub fn new(name: impl Into<String>, data_type: DataType, nullable: bool) -> Self
Creates a new field
sourcepub fn new_dict(
name: impl Into<String>,
data_type: DataType,
nullable: bool,
dict_id: i64,
dict_is_ordered: bool
) -> Self
pub fn new_dict( name: impl Into<String>, data_type: DataType, nullable: bool, dict_id: i64, dict_is_ordered: bool ) -> Self
Creates a new field that has additional dictionary information
sourcepub fn new_dictionary(
name: impl Into<String>,
key: DataType,
value: DataType,
nullable: bool
) -> Self
pub fn new_dictionary( name: impl Into<String>, key: DataType, value: DataType, nullable: bool ) -> Self
Create a new Field
with DataType::Dictionary
Use Self::new_dict
for more advanced dictionary options
Panics
Panics if !key.is_dictionary_key_type
sourcepub fn new_struct(
name: impl Into<String>,
fields: impl Into<Fields>,
nullable: bool
) -> Self
pub fn new_struct( name: impl Into<String>, fields: impl Into<Fields>, nullable: bool ) -> Self
Create a new Field
with DataType::Struct
name
: the name of theDataType::Struct
fieldfields
: the description of each struct elementnullable
: if theDataType::Struct
array is nullable
sourcepub fn new_list(
name: impl Into<String>,
value: impl Into<FieldRef>,
nullable: bool
) -> Self
pub fn new_list( name: impl Into<String>, value: impl Into<FieldRef>, nullable: bool ) -> Self
Create a new Field
with DataType::List
name
: the name of theDataType::List
fieldvalue
: the description of each list elementnullable
: if theDataType::List
array is nullable
sourcepub fn new_large_list(
name: impl Into<String>,
value: impl Into<FieldRef>,
nullable: bool
) -> Self
pub fn new_large_list( name: impl Into<String>, value: impl Into<FieldRef>, nullable: bool ) -> Self
Create a new Field
with DataType::LargeList
name
: the name of theDataType::LargeList
fieldvalue
: the description of each list elementnullable
: if theDataType::LargeList
array is nullable
sourcepub fn new_map(
name: impl Into<String>,
entries: impl Into<String>,
keys: impl Into<FieldRef>,
values: impl Into<FieldRef>,
sorted: bool,
nullable: bool
) -> Self
pub fn new_map( name: impl Into<String>, entries: impl Into<String>, keys: impl Into<FieldRef>, values: impl Into<FieldRef>, sorted: bool, nullable: bool ) -> Self
Create a new Field
with DataType::Map
name
: the name of theDataType::Map
fieldentries
: the name of the innerDataType::Struct
fieldkeys
: the map keysvalues
: the map valuessorted
: if theDataType::Map
array is sortednullable
: if theDataType::Map
array is nullable
sourcepub fn new_union<S, F, T>(
name: S,
type_ids: T,
fields: F,
mode: UnionMode
) -> Selfwhere
S: Into<String>,
F: IntoIterator,
F::Item: Into<FieldRef>,
T: IntoIterator<Item = i8>,
pub fn new_union<S, F, T>( name: S, type_ids: T, fields: F, mode: UnionMode ) -> Selfwhere S: Into<String>, F: IntoIterator, F::Item: Into<FieldRef>, T: IntoIterator<Item = i8>,
Create a new Field
with DataType::Union
name
: the name of theDataType::Union
fieldtype_ids
: the union type idsfields
: the union fieldsmode
: the union mode
sourcepub fn set_metadata(&mut self, metadata: HashMap<String, String>)
pub fn set_metadata(&mut self, metadata: HashMap<String, String>)
Sets the Field
’s optional custom metadata.
sourcepub fn with_metadata(self, metadata: HashMap<String, String>) -> Self
pub fn with_metadata(self, metadata: HashMap<String, String>) -> Self
Sets the metadata of this Field
to be metadata
and returns self
sourcepub const fn metadata(&self) -> &HashMap<String, String>
pub const fn metadata(&self) -> &HashMap<String, String>
Returns the immutable reference to the Field
’s optional custom metadata.
sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Set the name of the Field
and returns self.
let field = Field::new("c1", DataType::Int64, false)
.with_name("c2");
assert_eq!(field.name(), "c2");
sourcepub fn with_data_type(self, data_type: DataType) -> Self
pub fn with_data_type(self, data_type: DataType) -> Self
sourcepub const fn is_nullable(&self) -> bool
pub const fn is_nullable(&self) -> bool
Indicates whether this Field
supports null values.
sourcepub fn with_nullable(self, nullable: bool) -> Self
pub fn with_nullable(self, nullable: bool) -> Self
Set nullable
of the Field
and returns self.
let field = Field::new("c1", DataType::Int64, false)
.with_nullable(true);
assert_eq!(field.is_nullable(), true);
sourcepub const fn dict_id(&self) -> Option<i64>
pub const fn dict_id(&self) -> Option<i64>
Returns the dictionary ID, if this is a dictionary type.
sourcepub const fn dict_is_ordered(&self) -> Option<bool>
pub const fn dict_is_ordered(&self) -> Option<bool>
Returns whether this Field
’s dictionary is ordered, if this is a dictionary type.
sourcepub fn try_merge(&mut self, from: &Field) -> Result<(), ArrowError>
pub fn try_merge(&mut self, from: &Field) -> Result<(), ArrowError>
Merge this field into self if it is compatible.
Struct fields are merged recursively.
NOTE: self
may be updated to a partial / unexpected state in case of merge failure.
Example:
let mut field = Field::new("c1", DataType::Int64, false);
assert!(field.try_merge(&Field::new("c1", DataType::Int64, true)).is_ok());
assert!(field.is_nullable());
Trait Implementations§
source§impl Extend<Field> for SchemaBuilder
impl Extend<Field> for SchemaBuilder
source§fn extend<T: IntoIterator<Item = Field>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Field>>(&mut self, iter: T)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl FromIterator<Field> for Fields
impl FromIterator<Field> for Fields
source§impl Ord for Field
impl Ord for Field
source§impl PartialEq<Field> for Field
impl PartialEq<Field> for Field
source§impl PartialOrd<Field> for Field
impl PartialOrd<Field> for Field
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more