Skip to content
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

[SPARK-50354][SQL] No need to set initialInputBufferOffset when Aggregate mode is Complete #48895

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zhixingheyi-tian
Copy link
Contributor

@zhixingheyi-tian zhixingheyi-tian commented Nov 19, 2024

What changes were proposed in this pull request?

Here:

if isHashBasedAggWithKeys(partialAgg) && isPartialAgg(partialAgg, hashAgg) =>
if (SortOrder.orderingSatisfies(
partialAgg.child.outputOrdering, sortAgg.requiredChildOrdering.head)) {
sortAgg.copy(
aggregateExpressions = sortAgg.aggregateExpressions.map(_.copy(mode = Complete)),
child = partialAgg.child)

            if isHashBasedAggWithKeys(partialAgg) && isPartialAgg(partialAgg, hashAgg) =>
            if (SortOrder.orderingSatisfies(
                partialAgg.child.outputOrdering, sortAgg.requiredChildOrdering.head)) {
              sortAgg.copy(
                aggregateExpressions = sortAgg.aggregateExpressions.map(_.copy(mode = Complete)),
                child = partialAgg.child) 

Here. sortAgg comes from Final Aggregate, now becomes Complete mode. So need to disable the original initialInputBufferOffset

Just a small flaw.

Why are the changes needed?

This makes the code more rigorous.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Existed UTs

@github-actions github-actions bot added the SQL label Nov 19, 2024
@zhixingheyi-tian zhixingheyi-tian changed the title [SPARK-37455][SQL] No need to set initialInputBufferOffset when Aggre… [SPARK-37455][SQL] No need to set initialInputBufferOffset when Aggregate mode is Complete Nov 19, 2024
@zhixingheyi-tian zhixingheyi-tian changed the title [SPARK-37455][SQL] No need to set initialInputBufferOffset when Aggregate mode is Complete [SPARK-50354][SQL] No need to set initialInputBufferOffset when Aggregate mode is Complete Nov 19, 2024
@zhixingheyi-tian
Copy link
Contributor Author

zhixingheyi-tian commented Nov 19, 2024

Copy link
Member

@dongjoon-hyun dongjoon-hyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for making a PR, @zhixingheyi-tian .

Could you elaborate about this claim in the PR description?

This makes the code more rigorous.

@@ -75,6 +75,7 @@ object ReplaceHashWithSortAgg extends Rule[SparkPlan] {
partialAgg.child.outputOrdering, sortAgg.requiredChildOrdering.head)) {
sortAgg.copy(
aggregateExpressions = sortAgg.aggregateExpressions.map(_.copy(mode = Complete)),
initialInputBufferOffset = 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you saying that this parameter is not used in complete-mode aggregation, so we should set it to 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just directly restore to the default value "0".

cc @dongjoon-hyun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants