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 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.
The metadata is set as None
for empty map.
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 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
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read more