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§
Sourcefn native(&self) -> &NativeType
fn native(&self) -> &NativeType
Get the native backing type of this logical type.
Sourcefn signature(&self) -> TypeSignature<'_>
fn signature(&self) -> TypeSignature<'_>
Get the unique type signature for this logical type. Logical types with identical signatures are considered equal.
Provided Methods§
Sourcefn default_cast_for(&self, origin: &DataType) -> Result<DataType>
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
impl Debug for dyn LogicalType
Source§impl Display for dyn LogicalType
impl Display for dyn LogicalType
impl Eq for dyn LogicalType
Source§impl Hash for dyn LogicalType
impl Hash for dyn LogicalType
Source§impl Ord for dyn LogicalType
impl Ord for dyn LogicalType
Source§impl PartialEq for dyn LogicalType
impl PartialEq for dyn LogicalType
Source§impl PartialOrd for dyn LogicalType
impl PartialOrd for dyn LogicalType
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".