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-32951][SQL] Foldable propagation from Aggregate #29816

Conversation

peter-toth
Copy link
Contributor

@peter-toth peter-toth commented Sep 21, 2020

What changes were proposed in this pull request?

This PR adds foldable propagation from Aggregate as per: #29771 (comment)

Why are the changes needed?

This is an improvement as Aggregate's aggregateExpressions can contain foldables that can be propagated up.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

New UT.

@peter-toth
Copy link
Contributor Author

@SparkQA
Copy link

SparkQA commented Sep 21, 2020

Test build #128933 has finished for PR 29816 at commit b6276c9.

  • This patch fails Spark unit tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@peter-toth peter-toth changed the title [SPARK-32951][SQL] Foldable propagation from Aggregate [SPARK-32951][SQL][WIP] Foldable propagation from Aggregate Sep 21, 2020
@peter-toth peter-toth changed the title [SPARK-32951][SQL][WIP] Foldable propagation from Aggregate [WIP][SPARK-32951][SQL] Foldable propagation from Aggregate Sep 21, 2020
/**
* List of all [[UnaryNode]]s which allow foldable propagation.
*/
private def canPropagateFoldables(u: UnaryNode): Boolean = u match {
// Handling `Project` is moved to `propagateFoldables`.
case _: Filter => true
case _: SubqueryAlias => true
case _: Aggregate => true
// Handling `Aggregate` is moved to `propagateFoldables`.
Copy link
Contributor

Choose a reason for hiding this comment

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

can we merge this comment with // Handling `Project` is moved to `propagateFoldables`.?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, will change it.

Copy link
Contributor

@cloud-fan cloud-fan left a comment

Choose a reason for hiding this comment

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

LGTM if tests can pass

@peter-toth
Copy link
Contributor Author

LGTM if tests can pass

I need to look into plan stability failures first.

@cloud-fan
Copy link
Contributor

you can just regenerate the golden file and push the change. Then the reviewers can look at the plan change and approve it if it's fine.

@peter-toth
Copy link
Contributor Author

you can just regenerate the golden file and push the change. Then the reviewers can look at the plan change and approve it if it's fine.

Thanks. I did it already but haven't had time to check the changes. Anyway, added it as a new commit.

@@ -73,19 +73,19 @@ Input [2]: [i_manufact#2, count#9]
Keys [1]: [i_manufact#2]
Functions [1]: [count(1)]
Aggregate Attributes [1]: [count(1)#11]
Results [3]: [count(1)#11 AS item_cnt#12, i_manufact#2 AS i_manufact#2#13, true AS alwaysTrue#14]
Results [2]: [count(1)#11 AS item_cnt#12, i_manufact#2 AS i_manufact#2#13]
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is a positive change.

Comment on lines +79 to +84
Input [2]: [item_cnt#12, i_manufact#2#13]
Condition : (item_cnt#12 > 0)

(13) Project [codegen id : 2]
Output [1]: [i_manufact#2#13]
Input [3]: [item_cnt#12, i_manufact#2#13, alwaysTrue#14]
Input [2]: [item_cnt#12, i_manufact#2#13]
Copy link
Member

Choose a reason for hiding this comment

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

this looks good.

@viirya
Copy link
Member

viirya commented Sep 21, 2020

Please remove [WIP] before merging.

@peter-toth peter-toth changed the title [WIP][SPARK-32951][SQL] Foldable propagation from Aggregate [SPARK-32951][SQL] Foldable propagation from Aggregate Sep 21, 2020
@peter-toth
Copy link
Contributor Author

Please remove [WIP] before merging.

Done, thanks.

@SparkQA
Copy link

SparkQA commented Sep 21, 2020

Test build #128943 has finished for PR 29816 at commit 474c7c0.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

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.

+1, LGTM. Thank you, @peter-toth , @cloud-fan , and @viirya .
Merged to master for Apache Spark 3.1.0 on December 2020.

@maropu
Copy link
Member

maropu commented Sep 23, 2020

late LGTM and thanks for the update, @peter-toth !

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.

6 participants