Struct datafusion::logical_expr::WindowUDF
source · pub struct WindowUDF { /* private fields */ }
Expand description
Logical representation of a user-defined window function (UDWF) A UDWF is different from a UDF in that it is stateful across batches.
See the documentation on PartitionEvaluator
for more details
-
For simple use cases, use
create_udwf
(examples insimple_udwf.rs
). -
For advanced use cases, use
WindowUDFImpl
which provides full API access (examples inadvanced_udwf.rs
).
§API Note
This is a separate struct from WindowUDFImpl
to maintain backwards
compatibility with the older API.
Implementations§
source§impl WindowUDF
impl WindowUDF
sourcepub fn new(
name: &str,
signature: &Signature,
return_type: &Arc<dyn Fn(&[DataType]) -> Result<Arc<DataType>, DataFusionError> + Sync + Send>,
partition_evaluator_factory: &Arc<dyn Fn() -> Result<Box<dyn PartitionEvaluator>, DataFusionError> + Sync + Send>,
) -> WindowUDF
👎Deprecated since 34.0.0: please implement WindowUDFImpl instead
pub fn new( name: &str, signature: &Signature, return_type: &Arc<dyn Fn(&[DataType]) -> Result<Arc<DataType>, DataFusionError> + Sync + Send>, partition_evaluator_factory: &Arc<dyn Fn() -> Result<Box<dyn PartitionEvaluator>, DataFusionError> + Sync + Send>, ) -> WindowUDF
Create a new WindowUDF from low level details.
See WindowUDFImpl
for a more convenient way to create a
WindowUDF
using trait objects
sourcepub fn new_from_impl<F>(fun: F) -> WindowUDFwhere
F: WindowUDFImpl + 'static,
pub fn new_from_impl<F>(fun: F) -> WindowUDFwhere
F: WindowUDFImpl + 'static,
Create a new WindowUDF
from a [WindowUDFImpl]
trait object
Note this is the same as using the From
impl (WindowUDF::from
)
sourcepub fn inner(&self) -> &Arc<dyn WindowUDFImpl>
pub fn inner(&self) -> &Arc<dyn WindowUDFImpl>
Return the underlying WindowUDFImpl
trait object for this function
sourcepub fn with_aliases(
self,
aliases: impl IntoIterator<Item = &'static str>,
) -> WindowUDF
pub fn with_aliases( self, aliases: impl IntoIterator<Item = &'static str>, ) -> WindowUDF
Adds additional names that can be used to invoke this function, in
addition to name
If you implement WindowUDFImpl
directly you should return aliases directly.
sourcepub fn call(&self, args: Vec<Expr>) -> Expr
pub fn call(&self, args: Vec<Expr>) -> Expr
creates a Expr
that calls the window function with default
values for order_by
, partition_by
, window_frame
.
See ExprFunctionExt
for details on setting these values.
This utility allows using a user defined window function without requiring access to the registry, such as with the DataFrame API.
sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns this function’s name
See WindowUDFImpl::name
for more details.
sourcepub fn signature(&self) -> &Signature
pub fn signature(&self) -> &Signature
Returns this function’s signature (what input types are accepted)
See WindowUDFImpl::signature
for more details.
sourcepub fn return_type(
&self,
args: &[DataType],
) -> Result<DataType, DataFusionError>
pub fn return_type( &self, args: &[DataType], ) -> Result<DataType, DataFusionError>
Return the type of the function given its input types
See WindowUDFImpl::return_type
for more details.
sourcepub fn simplify(
&self,
) -> Option<Box<dyn Fn(WindowFunction, &dyn SimplifyInfo) -> Result<Expr, DataFusionError>>>
pub fn simplify( &self, ) -> Option<Box<dyn Fn(WindowFunction, &dyn SimplifyInfo) -> Result<Expr, DataFusionError>>>
Do the function rewrite
See WindowUDFImpl::simplify
for more details.
sourcepub fn partition_evaluator_factory(
&self,
) -> Result<Box<dyn PartitionEvaluator>, DataFusionError>
pub fn partition_evaluator_factory( &self, ) -> Result<Box<dyn PartitionEvaluator>, DataFusionError>
Return a PartitionEvaluator
for evaluating this window function
Trait Implementations§
impl Eq for WindowUDF
Auto Trait Implementations§
impl Freeze for WindowUDF
impl !RefUnwindSafe for WindowUDF
impl Send for WindowUDF
impl Sync for WindowUDF
impl Unpin for WindowUDF
impl !UnwindSafe for WindowUDF
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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
key
and return true
if they are equal.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>
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>
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