-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Combine evaluate_stateful and evaluate_inside_range #6665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me @mustafasrepo and is a very nice cleanup. Thank you!
| /// | ||
| /// If `include_rank` is true, then [`Self::create_evaluator`] must | ||
| /// implement [`PartitionEvaluator::evaluate_with_rank`] | ||
| /// implement [`PartitionEvaluator::evaluate_with_rank_all`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you plan to give the same treatment (move to PartitionEvaluator) to include_rank?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do so, what do you think about it. Should we do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, I have moved include_rank flag to PartitionEvaluator also.
| ScalarValue::iter_to_array(res.into_iter()) | ||
| } else { | ||
| Err(DataFusionError::NotImplemented( | ||
| "evaluate_all is not implemented by default".into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| "evaluate_all is not implemented by default".into(), | |
| format!("evaluate_all is not implemented for {} when using window frames", self.name()), |
I think the error could be more helpful, but I can also add that as a follow on PR
alamb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great to me -- thanks again @mustafasrepo
| } | ||
|
|
||
| impl PartitionEvaluator for RankEvaluator { | ||
| fn get_range(&self, idx: usize, _n_rows: usize) -> Result<Range<usize>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
Which issue does this PR close?
Related to #5781
Rationale for this change
What changes are included in this PR?
This PR implements the proposal in the #PR12
evaluate_statefulandevaluate_inside_rangeare combined under singleevaluatemethodsuses_window_frameandsupports_bounded_executionmethods are moved fromBoundedWindowFunctionExprtoPartitionEvaluator.With the changes in this PR new Evaluators can be implemented according to table below.
evaluate_all(if we were to implementPERCENT_RANKit would end up in this quadrant, we cannot produce any result without seeing whole data)evaluate(optionally can also implementevaluate_allfor more optimized implementation. However, there will be default implementation that is suboptimal) . If we were to implementROW_NUMBERit will end up in this quadrant. ExampleOddRowNumbershowcases this use caseevaluate(I think as long asuses_window_frameistrue. There is no way forsupports_bounded_executionto be false). I couldn't come up with any example for this quadrantevaluate. If we were to implementFIRST_VALUE, it would end up in this quadrantAre these changes tested?
Are there any user-facing changes?