Path: blob/main/crates/polars-plan/src/plans/aexpr/function_expr/extension.rs
7889 views
use super::*;12#[cfg_attr(feature = "ir_serde", derive(serde::Serialize, serde::Deserialize))]3#[derive(Clone, PartialEq, Debug, Eq, Hash)]4pub enum IRExtensionFunction {5To(DataType),6Storage,7}89impl IRExtensionFunction {10pub(super) fn get_field(&self, mapper: FieldsMapper) -> PolarsResult<Field> {11use IRExtensionFunction::*;12match self {13To(dtype) => mapper.with_dtype(dtype.clone()),14Storage => mapper.map_dtype(|dt| match dt {15DataType::Extension(_, storage) => (**storage).clone(),16dt => dt.clone(),17}),18}19}2021pub fn function_options(&self) -> FunctionOptions {22use IRExtensionFunction::*;23match self {24To(_dtype) => FunctionOptions::elementwise(),25Storage => FunctionOptions::elementwise(),26}27}28}2930impl Display for IRExtensionFunction {31fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {32use IRExtensionFunction::*;33match self {34To(dtype) => write!(f, "ext.to({dtype:?})"),35Storage => write!(f, "ext.storage()"),36}37}38}3940impl From<IRExtensionFunction> for IRFunctionExpr {41fn from(func: IRExtensionFunction) -> Self {42IRFunctionExpr::Extension(func)43}44}454647