-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Combine evaluate_stateful and evaluate_inside_range #6665
Conversation
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!
/// Can this function be evaluated with (only) rank | ||
/// | ||
/// 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
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
@@ -115,12 +115,6 @@ pub(crate) struct RankEvaluator { | |||
} | |||
|
|||
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_stateful
andevaluate_inside_range
are combined under singleevaluate
methodsuses_window_frame
andsupports_bounded_execution
methods are moved fromBoundedWindowFunctionExpr
toPartitionEvaluator
.With the changes in this PR new Evaluators can be implemented according to table below.
evaluate_all
(if we were to implementPERCENT_RANK
it would end up in this quadrant, we cannot produce any result without seeing whole data)evaluate
(optionally can also implementevaluate_all
for more optimized implementation. However, there will be default implementation that is suboptimal) . If we were to implementROW_NUMBER
it will end up in this quadrant. ExampleOddRowNumber
showcases this use caseevaluate
(I think as long asuses_window_frame
istrue
. There is no way forsupports_bounded_execution
to 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?