pub enum Coercion {
Exact {
desired_type: TypeSignatureClass,
},
Implicit {
desired_type: TypeSignatureClass,
implicit_coercion: ImplicitCoercion,
},
}
Expand description
Represents type coercion rules for function arguments, specifying both the desired type and optional implicit coercion rules for source types.
§Examples
use datafusion_expr_common::signature::{Coercion, TypeSignatureClass};
use datafusion_common::types::{NativeType, logical_binary, logical_string};
// Exact coercion that only accepts timestamp types
let exact = Coercion::new_exact(TypeSignatureClass::Timestamp);
// Implicit coercion that accepts string types but can coerce from binary types
let implicit = Coercion::new_implicit(
TypeSignatureClass::Native(logical_string()),
vec![TypeSignatureClass::Native(logical_binary())],
NativeType::String
);
There are two variants:
Exact
- Only accepts arguments that exactly match the desired typeImplicit
- Accepts the desired type and can coerce from specified source types
Variants§
Exact
Coercion that only accepts arguments exactly matching the desired type.
Fields
§
desired_type: TypeSignatureClass
The required type for the argument
Implicit
Coercion that accepts the desired type and can implicitly coerce from other types.
Fields
§
desired_type: TypeSignatureClass
The primary desired type for the argument
§
implicit_coercion: ImplicitCoercion
Rules for implicit coercion from other types
Implementations§
Source§impl Coercion
impl Coercion
pub fn new_exact(desired_type: TypeSignatureClass) -> Coercion
Sourcepub fn new_implicit(
desired_type: TypeSignatureClass,
allowed_source_types: Vec<TypeSignatureClass>,
default_casted_type: NativeType,
) -> Coercion
pub fn new_implicit( desired_type: TypeSignatureClass, allowed_source_types: Vec<TypeSignatureClass>, default_casted_type: NativeType, ) -> Coercion
Create a new coercion with implicit coercion rules.
allowed_source_types
defines the possible types that can be coerced to desired_type
.
default_casted_type
is the default type to be used for coercion if we cast from other types via allowed_source_types
.
pub fn allowed_source_types(&self) -> &[TypeSignatureClass]
pub fn default_casted_type(&self) -> Option<&NativeType>
pub fn desired_type(&self) -> &TypeSignatureClass
pub fn implicit_coercion(&self) -> Option<&ImplicitCoercion>
Trait Implementations§
Source§impl PartialOrd for Coercion
impl PartialOrd for Coercion
impl Eq for Coercion
Auto Trait Implementations§
impl Freeze for Coercion
impl !RefUnwindSafe for Coercion
impl Send for Coercion
impl Sync for Coercion
impl Unpin for Coercion
impl !UnwindSafe for Coercion
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more