Skip to main content

ScalarUdfTester

Struct ScalarUdfTester 

Source
pub struct ScalarUdfTester { /* private fields */ }
Expand description

Low-level tester for scalar functions

This struct provides a means by which to run a simple check of an scalar UDF implementation by simulating how DataFusion might call it.

This is not a replacement for testing at a higher level using DataFusion’s actual implementation but provides a useful mechanism to ensure all the pieces of an scalar UDF are plugged in.

Note that arguments are always cast to the values passed Self::new: to test different combinations of argument types, use a new tester.

Implementations§

Source§

impl ScalarUdfTester

Source

pub fn new(udf: ScalarUDF, arg_types: Vec<SedonaType>) -> Self

Create a new tester

Source

pub fn config_options(&self) -> &ConfigOptions

Returns the ConfigOptions used when invoking the UDF.

This is the same structure DataFusion threads through ScalarFunctionArgs. Sedona-specific options are stored in config_options.extensions.

Source

pub fn config_options_mut(&mut self) -> &mut ConfigOptions

Returns a mutable reference to the ConfigOptions used when invoking the UDF.

Use this to tweak DataFusion options or to insert/update Sedona options via config_options.extensions before calling the tester’s invoke_* helpers.

Source

pub fn sedona_options(&self) -> &SedonaOptions

Returns the SedonaOptions stored in config_options.extensions, if present.

Source

pub fn sedona_options_mut(&mut self) -> &mut SedonaOptions

Returns a mutable reference to the SedonaOptions stored in config_options.extensions, if present.

Source

pub fn assert_return_type(&self, data_type: impl TryInto<SedonaType>)

Assert the return type of the function for the argument types used to construct this tester

Both SedonaType or DataType objects can be used as the expected data type.

Source

pub fn assert_scalar_result_equals( &self, actual: impl Literal, expected: impl Literal, )

Assert the result of invoking this function

Both actual and expected are interpreted according to the calculated return type (notably, WKT is interpreted as geometry or geography output).

Source

pub fn assert_scalar_result_equals_with_return_type( &self, actual: impl Literal, expected: impl Literal, return_type: SedonaType, )

Assert the result of invoking this function with the return type specified

This is for UDFs implementing SedonaScalarKernel::return_type_from_args_and_scalars().

Source

pub fn return_type(&self) -> Result<SedonaType>

Compute the return type

Source

pub fn return_type_with_scalar( &self, arg0: Option<impl Literal>, ) -> Result<SedonaType>

Compute the return type from one scalar argument

This is for UDFs implementing SedonaScalarKernel::return_type_from_args_and_scalars().

Source

pub fn return_type_with_scalar_scalar( &self, arg0: Option<impl Literal>, arg1: Option<impl Literal>, ) -> Result<SedonaType>

Compute the return type from two scalar arguments

This is for UDFs implementing SedonaScalarKernel::return_type_from_args_and_scalars().

Source

pub fn return_type_with_scalar_scalar_scalar( &self, arg0: Option<impl Literal>, arg1: Option<impl Literal>, arg2: Option<impl Literal>, ) -> Result<SedonaType>

Compute the return type from three scalar arguments

This is for UDFs implementing SedonaScalarKernel::return_type_from_args_and_scalars().

Source

pub fn invoke_scalar(&self, arg: impl Literal) -> Result<ScalarValue>

Invoke this function with a scalar

Source

pub fn invoke_wkb_scalar(&self, wkt_value: Option<&str>) -> Result<ScalarValue>

Invoke this function with a geometry scalar

Source

pub fn invoke_scalar_scalar<T0: Literal, T1: Literal>( &self, arg0: T0, arg1: T1, ) -> Result<ScalarValue>

Invoke this function with two scalars

Source

pub fn invoke_scalar_scalar_scalar<T0: Literal, T1: Literal, T2: Literal>( &self, arg0: T0, arg1: T1, arg2: T2, ) -> Result<ScalarValue>

Invoke this function with three scalars

Source

pub fn invoke_wkb_array( &self, wkb_values: Vec<Option<&str>>, ) -> Result<ArrayRef>

Invoke this function with a geometry array

Source

pub fn invoke_wkb_array_scalar( &self, wkb_values: Vec<Option<&str>>, arg: impl Literal, ) -> Result<ArrayRef>

Invoke this function with a geometry array and a scalar

Source

pub fn invoke_array(&self, array: ArrayRef) -> Result<ArrayRef>

Invoke this function with an array

Source

pub fn invoke_array_scalar( &self, array: ArrayRef, arg: impl Literal, ) -> Result<ArrayRef>

Invoke a binary function with an array and a scalar

Source

pub fn invoke_array_scalar_scalar( &self, array: ArrayRef, arg0: impl Literal, arg1: impl Literal, ) -> Result<ArrayRef>

Invoke a binary function with an array, and two scalars

Source

pub fn invoke_scalar_array( &self, arg: impl Literal, array: ArrayRef, ) -> Result<ArrayRef>

Invoke a binary function with a scalar and an array

Source

pub fn invoke_array_array( &self, array0: ArrayRef, array1: ArrayRef, ) -> Result<ArrayRef>

Invoke a binary function with two arrays

Source

pub fn invoke_array_array_scalar( &self, array0: ArrayRef, array1: ArrayRef, arg: impl Literal, ) -> Result<ArrayRef>

Invoke a binary function with two arrays and a scalar

Source

pub fn invoke_arrays(&self, arrays: Vec<ArrayRef>) -> Result<ArrayRef>

Source

pub fn invoke(&self, args: Vec<ColumnarValue>) -> Result<ColumnarValue>

Source

pub fn invoke_with_return_type( &self, args: Vec<ColumnarValue>, return_type: Option<SedonaType>, ) -> Result<ColumnarValue>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V