Combine evaluate_stateful and evaluate_inside_range#6665
Merged
alamb merged 6 commits intoapache:mainfrom Jun 14, 2023
synnada-ai:feature/refactor_window_eval
Merged
Combine evaluate_stateful and evaluate_inside_range#6665alamb merged 6 commits intoapache:mainfrom synnada-ai:feature/refactor_window_eval
alamb merged 6 commits intoapache:mainfrom
synnada-ai:feature/refactor_window_eval
Conversation
alamb
approved these changes
Jun 14, 2023
Contributor
alamb
left a comment
There was a problem hiding this comment.
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`] |
Contributor
There was a problem hiding this comment.
Do you plan to give the same treatment (move to PartitionEvaluator) to include_rank?
Contributor
Author
There was a problem hiding this comment.
We can do so, what do you think about it. Should we do that?
Contributor
Author
There was a problem hiding this comment.
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(), |
Contributor
There was a problem hiding this comment.
Suggested change
| "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
approved these changes
Jun 14, 2023
Contributor
alamb
left a comment
There was a problem hiding this comment.
Looks great to me -- thanks again @mustafasrepo
| } | ||
|
|
||
| impl PartitionEvaluator for RankEvaluator { | ||
| fn get_range(&self, idx: usize, _n_rows: usize) -> Result<Range<usize>> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?