Uh oh!
There was an error while loading. Please reload this page.
[SPARK-32360][SQL] Add MaxMinBy to support eliminate sorts - #29142
[SPARK-32360][SQL] Add MaxMinBy to support eliminate sorts#29142ulysses-you wants to merge 4 commits into
Conversation
SparkQA
commented
Jul 17, 2020
Test build #126034 has finished for PR 29142 at commit
|
ulysses-you
commented
Jul 18, 2020
cc @maropu |
| private def isOrderIrrelevantAggs(aggs: Seq[NamedExpression]): Boolean = { | ||
| def isOrderIrrelevantAggFunction(func: AggregateFunction): Boolean = func match { | ||
| case _: Min | _: Max | _: Count => true | ||
| case _: Min | _: Max | _: Count | _: CountIf | _: MaxMinBy => true |
There was a problem hiding this comment.
count_if has replaced with count and if, so needn't add it.
SparkQA
commented
Jul 18, 2020
Test build #126101 has finished for PR 29142 at commit
|
dongjoon-hyun
commented
Jul 19, 2020
Retest this please. |
There was a problem hiding this comment.
Apache Spark community really appreciates your continuously contributions. Here are some advices for your contributions.
- Your contribution is good. However, please be aware of the non-code Apache Spark community policy. For example, release cycle and versioning. For example, SPARK-29343 is already released at 3.0.0 and your improvement patch will be applied only at 3.1.0. You need to use a new JIRA ID.
- You had better choose the most specific PR title. For example, this PR only add
MaxMinBy. If then, just sayAdd MaxMinByinstead ofAdd more aggregate function. - Please provide a test coverage when you add a new code path. More specifically, we need a test case which fails at
masterbranch and succeeds at your PR. The test coverage is very crucial to protect your contribution from accidental removal at future releases.
The above is a general guideline for you. We want to help you grow in the Apache Spark community and to go with us further. In addition, the above guideline will help you work in another Apache community, too. Thank you always, @ulysses-you .
SparkQA
commented
Jul 19, 2020
Test build #126135 has finished for PR 29142 at commit
|
ulysses-you
commented
Jul 20, 2020
Thank you @dongjoon-hyun , your advice is really helpful to me. I will follow up the policy that you said and keep contribute continuously. Thanks again! |
SparkQA
commented
Jul 20, 2020
Test build #126137 has finished for PR 29142 at commit
|
dongjoon-hyun
commented
Jul 20, 2020
Thank you for your update. Could you fix the UT failure? The newly add UT is failing now. |
| private def isOrderIrrelevantAggs(aggs: Seq[NamedExpression]): Boolean = { | ||
| def isOrderIrrelevantAggFunction(func: AggregateFunction): Boolean = func match { | ||
| case _: Min | _: Max | _: Count => true | ||
| case _: Min | _: Max | _: Count | _: MaxMinBy => true |
There was a problem hiding this comment.
Adding this itself looks fine to me.
SparkQA
commented
Jul 20, 2020
Test build #126145 has finished for PR 29142 at commit
|
There was a problem hiding this comment.
Hi, @ulysses-you and @maropu . Unfortunately, MaxBy and MinBy is order-sensitive. I'm -1 for this optimization.
scala> sql("SELECT max_by(x, y) FROM (SELECT * FROM VALUES (('a', 50)), (('b', 50)), (('c', 50)) AS tab(x, y) ORDER BY x)").show
+------------+
|max_by(x, y)|
+------------+
| c|
+------------+
scala> sql("SELECT max_by(x, y) FROM (SELECT * FROM VALUES (('a', 50)), (('b', 50)), (('c', 50)) AS tab(x, y) ORDER BY x DESC)").show
+------------+
|max_by(x, y)|
+------------+
| a|
+------------+
Could you close this PR please, @ulysses-you ? Or, could you let me know what I missed in your proposal? |
ulysses-you
commented
Jul 20, 2020
Thanks for the negative case, seems I missed something. |
Thank you for closing, @ulysses-you . |
dongjoon-hyun
commented
Jul 21, 2020
cc @gatorsmile |
What changes were proposed in this pull request?
Add
MaxMinByaggregate function and make these case support eliminate sorts.Why are the changes needed?
Make
EliminateSortsmatch more case.Does this PR introduce any user-facing change?
Yes, if match case user will see the different execution plan.
before
after
How was this patch tested?
manual test.