datafusion_common::types

Trait LogicalType

Source
pub trait LogicalType: Sync + Send {
    // Required methods
    fn native(&self) -> &NativeType;
    fn signature(&self) -> TypeSignature<'_>;

    // Provided method
    fn default_cast_for(&self, origin: &DataType) -> Result<DataType> { ... }
}
Expand description

Representation of a logical type with its signature and its native backing type.

The logical type is meant to be used during the DataFusion logical planning phase in order to reason about logical types without worrying about their underlying physical implementation.

§Extension types

LogicalType is a trait in order to allow the possibility of declaring extension types:

use datafusion_common::types::{LogicalType, NativeType, TypeSignature};

struct JSON {}

impl LogicalType for JSON {
    fn native(&self) -> &NativeType {
        &NativeType::String
    }

   fn signature(&self) -> TypeSignature<'_> {
       TypeSignature::Extension {
           name: "JSON",
           parameters: &[],
       }
   }
}

Required Methods§

Source

fn native(&self) -> &NativeType

Get the native backing type of this logical type.

Source

fn signature(&self) -> TypeSignature<'_>

Get the unique type signature for this logical type. Logical types with identical signatures are considered equal.

Provided Methods§

Source

fn default_cast_for(&self, origin: &DataType) -> Result<DataType>

Get the default physical type to cast origin to in order to obtain a physical type that is logically compatible with this logical type.

Trait Implementations§

Source§

impl Debug for dyn LogicalType

Source§

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

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

impl Hash for dyn LogicalType

Source§

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

Feeds this value into the given Hasher. Read more
Source§

impl Ord for dyn LogicalType

Source§

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

This method returns an Ordering between self and other. Read more
Source§

impl PartialEq for dyn LogicalType

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for dyn LogicalType

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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Eq for dyn LogicalType

Implementors§