Struct datafusion_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: &ReturnTypeFunction,
partition_evaluator_factory: &PartitionEvaluatorFactory,
) -> Self
👎Deprecated since 34.0.0: please implement WindowUDFImpl instead
pub fn new( name: &str, signature: &Signature, return_type: &ReturnTypeFunction, partition_evaluator_factory: &PartitionEvaluatorFactory, ) -> Self
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>,
) -> Self
pub fn with_aliases( self, aliases: impl IntoIterator<Item = &'static str>, ) -> Self
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>
pub fn return_type(&self, args: &[DataType]) -> Result<DataType>
Return the type of the function given its input types
See WindowUDFImpl::return_type
for more details.
sourcepub fn simplify(&self) -> Option<WindowFunctionSimplification>
pub fn simplify(&self) -> Option<WindowFunctionSimplification>
Do the function rewrite
See WindowUDFImpl::simplify
for more details.
sourcepub fn partition_evaluator_factory(&self) -> Result<Box<dyn PartitionEvaluator>>
pub fn partition_evaluator_factory(&self) -> Result<Box<dyn PartitionEvaluator>>
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.