mustafasrepo commented on code in PR #6621:
URL: https://github.com/apache/arrow-datafusion/pull/6621#discussion_r1226191313
##########
datafusion/physical-expr/src/window/nth_value.rs:
##########
@@ -169,9 +164,35 @@ impl PartitionEvaluator for NthValueEvaluator {
Ok(())
}
- fn set_state(&mut self, state: &BuiltinWindowState) -> Result<()> {
- if let BuiltinWindowState::NthValue(nth_value_state) = state {
- self.state = nth_value_state.clone()
+ /// When the window frame has a fixed beginning (e.g UNBOUNDED
+ /// PRECEDING), some functions such as FIRST_VALUE, LAST_VALUE and
+ /// NTH_VALUE we can memoize result. Once result is calculated it
+ /// will always stay same. Hence, we do not need to keep past data
+ /// as we process the entire dataset. This feature enables us to
+ /// prune rows from table. The default implementation does nothing
+ fn memoize(&mut self, state: &mut WindowAggState) -> Result<()> {
+ let out = &state.out_col;
+ let size = out.len();
+ let (is_prunable, new_prunable) = match self.state.kind {
Review Comment:
I know that is is not introduced here (and introduced by me) but while
reading the code maybe instead of `new_prunable` we can use `is_last` flag. I
think, that way intent will be more clear.
--
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]