comphead commented on code in PR #27466:
URL: https://github.com/apache/datafusion/pull/27466#discussion_r4757446421
##########
datafusion/physical-plan/src/windows/utils.rs:
##########
@@ -22,3 +26,69 @@ pub(crate) fn create_schema(
.finish()
.with_metadata(input_schema.metadata().clone()))
}
+
+/// Evaluates `window_expr` on each of the whole partitions of `batch` in
+/// `partitions`, and returns one array per window expression that covers
+/// `partitions` in order. An expression that evaluates several partitions in
+/// one call gets runs of at most `batch_size` rows, so that its frames stay
+/// batch-sized. A run of one partition, which can be larger, and a run that
+/// an expression declines are evaluated one partition at a time.
+pub(crate) fn compute_window_aggregates(
+ window_expr: &[Arc<dyn WindowExpr>],
+ batch: &RecordBatch,
+ partitions: &[Range<usize>],
+ batch_size: usize,
+) -> Result<Vec<ArrayRef>> {
+ // The arrays to concatenate for each expression
+ let mut results = vec![vec![]; window_expr.len()];
+ // The expressions that declined the current run
+ let mut per_partition = vec![];
+ for run in partition_runs(partitions, batch_size) {
+ per_partition.clear();
+ for (idx, expr) in window_expr.iter().enumerate() {
+ let result = if run.len() > 1 {
+ expr.evaluate_partitions(batch, run)?
Review Comment:
thats a good point
--
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]