Michael-J-Ward commented on code in PR #871:
URL: https://github.com/apache/datafusion-python/pull/871#discussion_r1765581243
##########
src/expr.rs:
##########
@@ -558,6 +561,45 @@ impl PyExpr {
pub fn window_frame(&self, window_frame: PyWindowFrame) ->
PyExprFuncBuilder {
self.expr.clone().window_frame(window_frame.into()).into()
}
+
+ #[pyo3(signature = (partition_by=None, window_frame=None, order_by=None,
null_treatment=None))]
+ pub fn over(
+ &self,
+ partition_by: Option<Vec<PyExpr>>,
+ window_frame: Option<PyWindowFrame>,
+ order_by: Option<Vec<PySortExpr>>,
+ null_treatment: Option<NullTreatment>,
+ ) -> PyResult<PyExpr> {
+ match &self.expr {
+ Expr::AggregateFunction(agg_fn) => {
+ let window_fn = Expr::WindowFunction(WindowFunction::new(
+
WindowFunctionDefinition::AggregateUDF(agg_fn.func.clone()),
+ agg_fn.args.clone(),
+ ));
+
+ add_builder_fns_to_window(
+ window_fn,
+ partition_by,
+ window_frame,
+ order_by,
+ null_treatment,
+ )
+ }
+ Expr::WindowFunction(_) => add_builder_fns_to_window(
+ self.expr.clone(),
+ partition_by,
+ window_frame,
+ order_by,
+ null_treatment,
+ ),
+ _ => Err(
+
DataFusionError::ExecutionError(datafusion::error::DataFusionError::Plan(
+ "Using `over` requires an aggregate function.".to_string(),
Review Comment:
```suggestion
format!("Using {} with `over` is not allowed. Must use
an aggregate or window function.", self.expr.variant_name())
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]