comphead commented on code in PR #27466:
URL: https://github.com/apache/datafusion/pull/27466#discussion_r4620298647
##########
datafusion/physical-expr/src/window/standard.rs:
##########
@@ -70,6 +71,54 @@ impl StandardWindowExpr {
}
Ok(())
}
+
+ /// Evaluates `evaluator`, which uses the window frame, on the frame of
every
+ /// row of `partitions`, consecutive ranges of whole partitions in `batch`,
+ /// in one call
+ fn evaluate_frames(
+ &self,
+ mut evaluator: Box<dyn PartitionEvaluator>,
+ batch: &RecordBatch,
+ partitions: &[Range<usize>],
+ ) -> Result<ArrayRef> {
+ // Rows outside `partitions` are not evaluated
+ let offset = partitions.first().map_or(0, |p| p.start);
+ let num_rows = partitions.last().map_or(0, |p| p.end) - offset;
+ let batch = batch.slice(offset, num_rows);
+ let mut values = self.evaluate_args(&batch)?;
+ let order_bys = get_orderby_values(self.order_by_columns(&batch)?);
+ let sort_options = self.order_by.iter().map(|o| o.options).collect();
+ let mut window_frame_ctx =
+ WindowFrameContext::new(Arc::clone(&self.window_frame),
sort_options);
+ let mut partition_order_bys = Vec::with_capacity(order_bys.len());
+ let mut ranges = Vec::with_capacity(num_rows);
+ for partition in partitions {
+ let start = partition.start - offset;
+ partition_order_bys.clear();
+ partition_order_bys.extend(
+ order_bys
+ .iter()
+ .map(|column| column.slice(start, partition.len())),
+ );
+ // Only the state of a GROUPS frame is specific to a partition
Review Comment:
Applied.
--
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]