-
Notifications
You must be signed in to change notification settings - Fork 566
[VL] Do not rewriteAggBufferAttributes for Complete agg mode #11358
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
rui-mo
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.
Could you please clarify if this change fixes an existing problem? Thanks.
|
@rui-mo During our implementation of hybrid AGG (where a single AGG contains both partial-merge and complete modes), we discovered this issue: |
| // Add a projection node before aggregation for row constructing. | ||
| // Mainly used for aggregation whose intermediate type is a compound type in Velox. | ||
| // Pre-projection is never required for final stages. | ||
| private def applyRowConstruct( |
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.
Why would this be called for the Complete mode, as rowConstructNeeded() returns false for it?
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.
Why would this be called for the Complete mode, as
rowConstructNeeded()returns false for it?
As mentioned earlier, we implemented a hybrid AGG that contains both PartialMerge (or Final) and complete aggregation functions, and rowConstructNeeded is triggered as long as a PartialMerge (or Final) function is present.
It won't be triggered for the now code, but I think we can add defensive code to handle this scenario in future implementations .
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.
rowConstructNeeded is triggered as long as a PartialMerge (or Final) function is present
Are you referring to the modified code on your side, or the current Gluten code?
As mentioned earlier, we implemented a hybrid AGG that contains both PartialMerge (or Final) and complete aggregation functions
Is there any plan to upstream this change to Gluten, or will it remain local to your side?
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.
Are you referring to the modified code on your side, or the current Gluten code?
The current Gluten code, see this
private def rowConstructNeeded(): Boolean = aggregateExpressions.exists {
case AggregateExpression(aggFunc, PartialMerge | Final, _, _, _) =>
aggFunc.inputAggBufferAttributes.size > 1
case _ => false
}Is there any plan to upstream this change to Gluten, or will it remain local to your side?
Oh, maybe it can be launched when it becomes stable!
| val functionInputAttributes = aggFunc.inputAggBufferAttributes | ||
| aggFunc match { | ||
| case _ if aggregateExpression.mode == Partial => | ||
| case _ if aggregateExpression.mode == Partial || aggregateExpression.mode == Complete => |
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.
I understand that mixing Complete mode with other modes isn’t supported, but is there a way to add a unit test for pure Complete mode to ensure this works?
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 already have pure complete mode case, see #7752, and it can run correctly
jackylee-ch
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.
LGTM. It also works in our environments.
What changes are proposed in this pull request?
rewriteAggBufferAttributes is only needed by PartialMerge and Final mode
How was this patch tested?
test by the existing cases