polars::prelude

Trait SchemaExt

Source
pub trait SchemaExt {
    // Required methods
    fn from_arrow_schema(value: &Schema<Field>) -> Self;
    fn get_field(&self, name: &str) -> Option<Field>;
    fn try_get_field(&self, name: &str) -> Result<Field, PolarsError>;
    fn to_arrow(&self, compat_level: CompatLevel) -> Schema<Field>;
    fn iter_fields(&self) -> impl ExactSizeIterator;
    fn to_supertype(
        &mut self,
        other: &Schema<DataType>,
    ) -> Result<bool, PolarsError>;
    fn materialize_unknown_dtypes(
        &self,
    ) -> Result<Schema<DataType>, PolarsError>;
}

Required Methods§

Source

fn from_arrow_schema(value: &Schema<Field>) -> Self

Source

fn get_field(&self, name: &str) -> Option<Field>

Source

fn try_get_field(&self, name: &str) -> Result<Field, PolarsError>

Source

fn to_arrow(&self, compat_level: CompatLevel) -> Schema<Field>

Source

fn iter_fields(&self) -> impl ExactSizeIterator

Source

fn to_supertype( &mut self, other: &Schema<DataType>, ) -> Result<bool, PolarsError>

Source

fn materialize_unknown_dtypes(&self) -> Result<Schema<DataType>, PolarsError>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SchemaExt for Schema<DataType>

Source§

fn get_field(&self, name: &str) -> Option<Field>

Look up the name in the schema and return an owned Field by cloning the data.

Returns None if the field does not exist.

This method constructs the Field by cloning the name and dtype. For a version that returns references, see [get][Self::get] or [get_full][Self::get_full].

Source§

fn try_get_field(&self, name: &str) -> Result<Field, PolarsError>

Look up the name in the schema and return an owned Field by cloning the data.

Returns Err(PolarsErr) if the field does not exist.

This method constructs the Field by cloning the name and dtype. For a version that returns references, see [get][Self::get] or [get_full][Self::get_full].

Source§

fn to_arrow(&self, compat_level: CompatLevel) -> Schema<Field>

Convert self to ArrowSchema by cloning the fields.

Source§

fn iter_fields(&self) -> impl ExactSizeIterator

Iterates the Fields in this schema, constructing them anew by cloning each (&name, &dtype) pair.

Note that this clones each name and dtype in order to form an owned Field. For a clone-free version, use [iter][Self::iter], which returns (&name, &dtype).

Source§

fn to_supertype( &mut self, other: &Schema<DataType>, ) -> Result<bool, PolarsError>

Take another Schema and try to find the supertypes between them.

Source§

fn materialize_unknown_dtypes(&self) -> Result<Schema<DataType>, PolarsError>

Materialize all unknown dtypes in this schema.

Source§

fn from_arrow_schema(value: &Schema<Field>) -> Schema<DataType>

Implementors§