Struct arrow_schema::Field

source ·
pub struct Field { /* private fields */ }
Expand description

Describes a single column in a Schema.

A Schema is an ordered collection of Field objects.

Implementations§

source§

impl Field

source

pub fn new(name: impl Into<String>, data_type: DataType, nullable: bool) -> Self

Creates a new field

source

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

source

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

source

pub fn new_struct( name: impl Into<String>, fields: impl Into<Fields>, nullable: bool ) -> Self

Create a new Field with DataType::Struct

source

pub fn new_list( name: impl Into<String>, value: impl Into<FieldRef>, nullable: bool ) -> Self

Create a new Field with DataType::List

source

pub fn new_large_list( name: impl Into<String>, value: impl Into<FieldRef>, nullable: bool ) -> Self

Create a new Field with DataType::LargeList

source

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

source

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 the DataType::Union field
  • type_ids: the union type ids
  • fields: the union fields
  • mode: the union mode
source

pub fn set_metadata(&mut self, metadata: HashMap<String, String>)

Sets the Field’s optional custom metadata.

source

pub fn with_metadata(self, metadata: HashMap<String, String>) -> Self

Sets the metadata of this Field to be metadata and returns self

source

pub const fn metadata(&self) -> &HashMap<String, String>

Returns the immutable reference to the Field’s optional custom metadata.

source

pub const fn name(&self) -> &String

Returns an immutable reference to the Field’s name.

source

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");
source

pub const fn data_type(&self) -> &DataType

Returns an immutable reference to the Field’s DataType.

source

pub fn with_data_type(self, data_type: DataType) -> Self

Set DataType of the Field and returns self.

let field = Field::new("c1", DataType::Int64, false)
   .with_data_type(DataType::Utf8);

assert_eq!(field.data_type(), &DataType::Utf8);
source

pub const fn is_nullable(&self) -> bool

Indicates whether this Field supports null values.

source

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);
source

pub const fn dict_id(&self) -> Option<i64>

Returns the dictionary ID, if this is a dictionary type.

source

pub const fn dict_is_ordered(&self) -> Option<bool>

Returns whether this Field’s dictionary is ordered, if this is a dictionary type.

source

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());
source

pub fn contains(&self, other: &Field) -> bool

Check to see if self is a superset of other field. Superset is defined as:

  • if nullability doesn’t match, self needs to be nullable
  • self.metadata is a superset of other.metadata
  • all other fields are equal
source

pub fn size(&self) -> usize

Return size of this instance in bytes.

Includes the size of Self.

Trait Implementations§

source§

impl Clone for Field

source§

fn clone(&self) -> Field

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Field

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Field

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Extend<Field> for SchemaBuilder

source§

fn extend<T: IntoIterator<Item = Field>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl FromIterator<Field> for Fields

source§

fn from_iter<T: IntoIterator<Item = Field>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl Hash for Field

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Field

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Field> for Field

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Field> for Field

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<&FFI_ArrowSchema> for Field

§

type Error = ArrowError

The type returned in the event of a conversion error.
source§

fn try_from(c_schema: &FFI_ArrowSchema) -> Result<Self, ArrowError>

Performs the conversion.
source§

impl TryFrom<&Field> for FFI_ArrowSchema

§

type Error = ArrowError

The type returned in the event of a conversion error.
source§

fn try_from(field: &Field) -> Result<Self, ArrowError>

Performs the conversion.
source§

impl TryFrom<Field> for FFI_ArrowSchema

§

type Error = ArrowError

The type returned in the event of a conversion error.
source§

fn try_from(field: Field) -> Result<Self, ArrowError>

Performs the conversion.
source§

impl Eq for Field

Auto Trait Implementations§

§

impl RefUnwindSafe for Field

§

impl Send for Field

§

impl Sync for Field

§

impl Unpin for Field

§

impl UnwindSafe for Field

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.