pub fn func_impl(
        &self,
        args: &[Arc<dyn PhysicalExpr>],
        schema: &Schema,
    ) -> Result<ScalarFunctionImplementation> {
        let func: ScalarFunctionImplementation = match self {
            BuiltinScalarFunction::ToYear => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_year(Date16Array) -> UInt16Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_year(Timestamp32Array, tz) -> UInt16Array)
                }
                other => wrap_type_err!(other, "toYear"),
            },
            BuiltinScalarFunction::ToMonth => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_month(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_month(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toMonth"),
            },
            BuiltinScalarFunction::ToDayOfYear => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_day_of_year(Date16Array) -> UInt16Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_day_of_year(Timestamp32Array, tz) -> UInt16Array)
                }
                other => wrap_type_err!(other, "toDayOfYear"),
            },
            BuiltinScalarFunction::ToDayOfMonth => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_day_of_month(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_day_of_month(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toDayOfMonth"),
            },
            BuiltinScalarFunction::ToDayOfWeek => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_day_of_week(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_day_of_week(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toDayOfWeek"),
            },
            BuiltinScalarFunction::ToDate => match args[0].data_type(schema) {
                Ok(DataType::Date16) => Arc::new(|args| Ok(args[0].clone())),
                Ok(DataType::Utf8) => wrap_string_fn!(fn utf8_to_date -> Date16Array),
                Ok(DataType::LargeUtf8) => {
                    wrap_string_fn!(fn large_utf8_to_date -> Date16Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_date(Timestamp32Array, tz) -> Date16Array)
                }
                Ok(DataType::Int64) => {
                    wrap_datetime_fn!(fn int64_to_date(Int64Array) -> Date16Array)
                }
                other => wrap_type_err!(other, "toDate"),
            },
            BuiltinScalarFunction::ToDateTime => match args[0].data_type(schema) {
                Ok(DataType::Utf8) => {
                    wrap_string_fn!(fn utf8_to_datetime -> Timestamp32Array)
                }
                Ok(DataType::LargeUtf8) => {
                    wrap_string_fn!(fn large_utf8_to_datetime -> Timestamp32Array)
                }
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date_to_datetime(Date16Array) -> Timestamp32Array)
                }
                Ok(DataType::Timestamp32(_tz)) => {
                    Arc::new(|timestamp| Ok(timestamp[0].clone()))
                }
                Ok(DataType::Int64) => {
                    wrap_datetime_fn!(fn int64_to_datetime(Int64Array) -> Timestamp32Array)
                }
                other => wrap_type_err!(other, "toDate"),
            },
            BuiltinScalarFunction::ToQuarter => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_quarter(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_quarter(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toQuarter"),
            },
            BuiltinScalarFunction::ToHour => match args[0].data_type(schema) {
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_hour(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toHour"),
            },
            BuiltinScalarFunction::ToMinute => match args[0].data_type(schema) {
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_minute(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toMinute"),
            },
            BuiltinScalarFunction::ToSecond => match args[0].data_type(schema) {
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_second(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toSecond"),
            },
            BuiltinScalarFunction::EndsWith => match args[0].data_type(schema) {
                Ok(DataType::Utf8) => wrap_string_fn!(fn utf8_ends_with -> BooleanArray),
                Ok(DataType::LargeUtf8) => {
                    wrap_string_fn!(fn large_utf8_ends_with -> BooleanArray)
                }
                other => wrap_type_err!(other, "endsWith"),
            },
        };

        Ok(func)
    }
/// Returns the implementation of the scalar function
Returns the implementation of the scalar function
Returns the implementation of the scalar function
pub fn func_impl(
        &self,
        args: &[Arc<dyn PhysicalExpr>],
        schema: &Schema,
    ) -> Result<ScalarFunctionImplementation> {
        let func: ScalarFunctionImplementation = match self {
            BuiltinScalarFunction::ToYear => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_year(Date16Array) -> UInt16Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_year(Timestamp32Array, tz) -> UInt16Array)
                }
                other => wrap_type_err!(other, "toYear"),
            },
            BuiltinScalarFunction::ToMonth => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_month(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_month(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toMonth"),
            },
            BuiltinScalarFunction::ToDayOfYear => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_day_of_year(Date16Array) -> UInt16Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_day_of_year(Timestamp32Array, tz) -> UInt16Array)
                }
                other => wrap_type_err!(other, "toDayOfYear"),
            },
            BuiltinScalarFunction::ToDayOfMonth => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_day_of_month(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_day_of_month(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toDayOfMonth"),
            },
            BuiltinScalarFunction::ToDayOfWeek => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_day_of_week(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_day_of_week(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toDayOfWeek"),
            },
            BuiltinScalarFunction::ToDate => match args[0].data_type(schema) {
                Ok(DataType::Date16) => Arc::new(|args| Ok(args[0].clone())),
                Ok(DataType::Utf8) => wrap_string_fn!(fn utf8_to_date -> Date16Array),
                Ok(DataType::LargeUtf8) => {
                    wrap_string_fn!(fn large_utf8_to_date -> Date16Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_date(Timestamp32Array, tz) -> Date16Array)
                }
                Ok(DataType::Int64) => {
                    wrap_datetime_fn!(fn int64_to_date(Int64Array) -> Date16Array)
                }
                other => wrap_type_err!(other, "toDate"),
            },
            BuiltinScalarFunction::ToDateTime => match args[0].data_type(schema) {
                Ok(DataType::Utf8) => {
                    wrap_string_fn!(fn utf8_to_datetime -> Timestamp32Array)
                }
                Ok(DataType::LargeUtf8) => {
                    wrap_string_fn!(fn large_utf8_to_datetime -> Timestamp32Array)
                }
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date_to_datetime(Date16Array) -> Timestamp32Array)
                }
                Ok(DataType::Timestamp32(_tz)) => {
                    Arc::new(|timestamp| Ok(timestamp[0].clone()))
                }
                Ok(DataType::Int64) => {
                    wrap_datetime_fn!(fn int64_to_datetime(Int64Array) -> Timestamp32Array)
                }
                other => wrap_type_err!(other, "toDate"),
            },
            BuiltinScalarFunction::ToQuarter => match args[0].data_type(schema) {
                Ok(DataType::Date16) => {
                    wrap_datetime_fn!(fn date16_to_quarter(Date16Array) -> UInt8Array)
                }
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_quarter(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toQuarter"),
            },
            BuiltinScalarFunction::ToHour => match args[0].data_type(schema) {
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_hour(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toHour"),
            },
            BuiltinScalarFunction::ToMinute => match args[0].data_type(schema) {
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_minute(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toMinute"),
            },
            BuiltinScalarFunction::ToSecond => match args[0].data_type(schema) {
                Ok(DataType::Timestamp32(tz)) => {
                    wrap_datetime_fn!(fn timestamp32_to_second(Timestamp32Array, tz) -> UInt8Array)
                }
                other => wrap_type_err!(other, "toSecond"),
            },
            BuiltinScalarFunction::EndsWith => match args[0].data_type(schema) {
                Ok(DataType::Utf8) => wrap_string_fn!(fn utf8_ends_with -> BooleanArray),
                Ok(DataType::LargeUtf8) => {
                    wrap_string_fn!(fn large_utf8_ends_with -> BooleanArray)
                }
                other => wrap_type_err!(other, "endsWith"),
            },
        };
        Ok(func)
    }
pub fn func_impl ( & self , args : & [ Arc < dyn PhysicalExpr > ] , schema : & Schema , ) -> Result < ScalarFunctionImplementation > { let func : ScalarFunctionImplementation = match self { BuiltinScalarFunction :: ToYear => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Date16 ) => { wrap_datetime_fn ! ( fn date16_to_year ( Date16Array ) UInt16Array ) } Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_year ( Timestamp32Array tz ) UInt16Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToMonth => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Date16 ) => { wrap_datetime_fn ! ( fn date16_to_month ( Date16Array ) UInt8Array ) } Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_month ( Timestamp32Array tz ) UInt8Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToDayOfYear => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Date16 ) => { wrap_datetime_fn ! ( fn date16_to_day_of_year ( Date16Array ) UInt16Array ) } Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_day_of_year ( Timestamp32Array tz ) UInt16Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToDayOfMonth => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Date16 ) => { wrap_datetime_fn ! ( fn date16_to_day_of_month ( Date16Array ) UInt8Array ) } Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_day_of_month ( Timestamp32Array tz ) UInt8Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToDayOfWeek => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Date16 ) => { wrap_datetime_fn ! ( fn date16_to_day_of_week ( Date16Array ) UInt8Array ) } Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_day_of_week ( Timestamp32Array tz ) UInt8Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToDate => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Date16 ) => Arc :: new ( | args | Ok ( args [ 0 ] . clone ( ) ) ) , Ok ( DataType :: Utf8 ) => wrap_string_fn ! ( fn utf8_to_date Date16Array ) , Ok ( DataType :: LargeUtf8 ) => { wrap_string_fn ! ( fn large_utf8_to_date Date16Array ) } Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_date ( Timestamp32Array tz ) Date16Array ) } Ok ( DataType :: Int64 ) => { wrap_datetime_fn ! ( fn int64_to_date ( Int64Array ) Date16Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToDateTime => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Utf8 ) => { wrap_string_fn ! ( fn utf8_to_datetime Timestamp32Array ) } Ok ( DataType :: LargeUtf8 ) => { wrap_string_fn ! ( fn large_utf8_to_datetime Timestamp32Array ) } Ok ( DataType :: Date16 ) => { wrap_datetime_fn ! ( fn date_to_datetime ( Date16Array ) Timestamp32Array ) } Ok ( DataType :: Timestamp32 ( _tz ) ) => { Arc :: new ( | timestamp | Ok ( timestamp [ 0 ] . clone ( ) ) ) } Ok ( DataType :: Int64 ) => { wrap_datetime_fn ! ( fn int64_to_datetime ( Int64Array ) Timestamp32Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToQuarter => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Date16 ) => { wrap_datetime_fn ! ( fn date16_to_quarter ( Date16Array ) UInt8Array ) } Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_quarter ( Timestamp32Array tz ) UInt8Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToHour => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_hour ( Timestamp32Array tz ) UInt8Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToMinute => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_minute ( Timestamp32Array tz ) UInt8Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: ToSecond => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Timestamp32 ( tz ) ) => { wrap_datetime_fn ! ( fn timestamp32_to_second ( Timestamp32Array tz ) UInt8Array ) } other => wrap_type_err ! ( other " " ) , } , BuiltinScalarFunction :: EndsWith => match args [ 0 ] . data_type ( schema ) { Ok ( DataType :: Utf8 ) => wrap_string_fn ! ( fn utf8_ends_with BooleanArray ) , Ok ( DataType :: LargeUtf8 ) => { wrap_string_fn ! ( fn large_utf8_ends_with BooleanArray ) } other => wrap_type_err ! ( other " " ) , } , } ; Ok ( func ) }
Returns the implementation of the scalar function
Returns the implementation of the scalar function
&self
args
&[Arc<dyn PhysicalExpr>]
schema
&Schema
&self
args
&[Arc<dyn PhysicalExpr>]
schema
&Schema