comphead commented on code in PR #9906:
URL: https://github.com/apache/arrow-datafusion/pull/9906#discussion_r1550140102
##########
datafusion/expr/src/udwf.rs:
##########
@@ -266,6 +290,35 @@ pub trait WindowUDFImpl: Debug + Send + Sync {
fn aliases(&self) -> &[String] {
&[]
}
+
+ /// Optionally apply per-UDWF simplification / rewrite rules.
+ ///
+ /// This can be used to apply function specific simplification rules during
+ /// optimization. The default implementation does nothing.
+ ///
+ /// Note that DataFusion handles simplifying arguments and "constant
+ /// folding" (replacing a function call with constant arguments such as
+ /// `my_add(1,2) --> 3` ). Thus, there is no need to implement such
+ /// optimizations manually for specific UDFs.
+ ///
+ /// Example:
+ /// [`advanced_udwf.rs`]:
<https://github.com/apache/arrow-datafusion/blob/main/datafusion-examples/examples/advanced_udwf.rs>
+ ///
+ /// # Returns
+ /// [`ExprSimplifyResult`] indicating the result of the simplification NOTE
+ /// if the function cannot be simplified, the arguments *MUST* be returned
+ /// unmodified
+ fn simplify(
+ &self,
+ args: Vec<Expr>,
+ _partition_by: &[Expr],
+ _order_by: &[Expr],
+ _window_frame: &WindowFrame,
Review Comment:
Thats probably better to use builder pattern, if the mandatory and optional
input params are different
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]