Struct arrow::datatypes::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) -> Field

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 ) -> Field

Creates a new field that has additional dictionary information

source

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

Sets the Field’s optional custom metadata.

source

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

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

source

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

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>) -> Field

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) -> Field

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) -> Field

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<(), Error>

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

impl Display for Field

source§

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

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

impl<'a> From<Field<'a>> for Field

Convert an IPC Field to Arrow Field

source§

fn from(field: Field<'_>) -> Field

Converts to this type from the input type.
source§

impl Hash for Field

source§

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

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: &Field) -> 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: &Field) -> 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: &Field) -> 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 PyArrowConvert for Field

source§

fn from_pyarrow(value: &PyAny) -> PyResult<Self>

source§

fn to_pyarrow(&self, py: Python<'_>) -> PyResult<PyObject>

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<Field, 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<FFI_ArrowSchema, 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<FFI_ArrowSchema, 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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
source§

impl<T> Allocation for Twhere T: RefUnwindSafe + Send + Sync,

source§

impl<T> Ungil for Twhere T: Send,