Uh oh!
There was an error while loading. Please reload this page.
[SPARK-20636] Add new optimization rule to transpose adjacent Window expressions. - #17899
[SPARK-20636] Add new optimization rule to transpose adjacent Window expressions.#17899ptkool wants to merge 12 commits into
Conversation
gatorsmile
commented
May 8, 2017
ok to test |
SparkQA
commented
May 8, 2017
Test build #76591 has finished for PR 17899 at commit
|
There was a problem hiding this comment.
This condition might not be enough. w1 might depend on the outputs of w2, right?
There was a problem hiding this comment.
You are also changing the order of the columns. You will need to add a projection on top to be sure.
SparkQA
commented
May 9, 2017
Test build #76678 has finished for PR 17899 at commit
|
SparkQA
commented
May 9, 2017
Test build #76679 has finished for PR 17899 at commit
|
SparkQA
commented
May 9, 2017
Test build #76680 has finished for PR 17899 at commit
|
f6a4e47 to
1ab81caCompareSparkQA
commented
May 9, 2017
Test build #76690 has finished for PR 17899 at commit
|
hvanhovell
commented
May 16, 2017
retest this please |
There was a problem hiding this comment.
This probably warrants a follow-up that tries to move projections that are wedged in between two window clauses.
There was a problem hiding this comment.
You need to check that the windows are independent, e.g.: w1.references.intersect(w2.windowOutputSet).isEmpty
There was a problem hiding this comment.
We might be able to get a little more milage out of the rule by using semanticEquals for comparing the partition expressions, e.g.:
defsliceSemanticEquals(ps1: Seq[Expression], ps2: Seq[Expression]):Boolean= ps1.zip(ps2).forall {
case (l, r) => l.semanticEquals(r)
}
...
sliceSemanticEquals(ps1, ps2)You could even get more leverage if you do not consider the order of the partition spec.
There was a problem hiding this comment.
Why this test? It does not really add anything new.
There was a problem hiding this comment.
comparePlans(optimized, analyzed)?
There was a problem hiding this comment.
I am not entirely sure if we need this test.
hvanhovell
left a comment
There was a problem hiding this comment.
@ptkool this looks pretty good. One thing need to be addressed though: we need to factor in that a parent window can depend on its child window.
SparkQA
commented
May 16, 2017
Test build #76970 has finished for PR 17899 at commit
|
1ab81ca to
f472bfeCompareSparkQA
commented
May 20, 2017
Test build #77126 has finished for PR 17899 at commit
|
ptkool
commented
Jun 3, 2017
@hvanhovell@gatorsmile Can you have another look at this? |
There was a problem hiding this comment.
No test case covers the condition w1.references.intersect(w2.windowOutputSet).isEmpty
There was a problem hiding this comment.
The expressions in both w1.expressions and w2.expressions must be deterministic. If not, we should not flip
There was a problem hiding this comment.
Why? This seems overly restrictive to me.
There was a problem hiding this comment.
Just to ensure the results are still the same with and without the rule.
f472bfe to
e2f24c2CompareSparkQA
commented
Jun 30, 2017
Test build #78973 has finished for PR 17899 at commit
|
gatorsmile
commented
Oct 28, 2017
@ptkool Can you address the conflicts? We will review it. |
SparkQA
commented
Oct 29, 2017
Test build #83189 has finished for PR 17899 at commit
|
SparkQA
commented
Oct 29, 2017
Test build #83191 has finished for PR 17899 at commit
|
82d7390 to
f840c69CompareSparkQA
commented
Oct 29, 2017
Test build #83193 has finished for PR 17899 at commit
|
SparkQA
commented
Oct 29, 2017
Test build #83194 has finished for PR 17899 at commit
|
SparkQA
commented
Jan 19, 2018
Test build #86355 has finished for PR 17899 at commit
|
SparkQA
commented
Sep 6, 2018
Test build #95753 has finished for PR 17899 at commit
|
| object CollapseWindow extends Rule[LogicalPlan] { | ||
| def apply(plan: LogicalPlan): LogicalPlan = plan transformUp { | ||
| case w1 @ Window(we1, ps1, os1, w2 @ Window(we2, ps2, os2, grandChild)) | ||
| if ps1 == ps2 && os1 == os2 && w1.references.intersect(w2.windowOutputSet).isEmpty && |
There was a problem hiding this comment.
I wouldn't include style changes
SparkQA
commented
Sep 7, 2018
Test build #95802 has finished for PR 17899 at commit
|
gatorsmile
left a comment
There was a problem hiding this comment.
LGTM
Thanks! Merged to master.
| } | ||
| /** | ||
| * Transpose Adjacent Window Expressions. |
## What changes were proposed in this pull request? This PR is a follow-up of the PR apache#17899. It is to add the rule TransposeWindow the optimizer batch. ## How was this patch tested? The existing tests. Closesapache#23222 from gatorsmile/followupSPARK-20636. Authored-by: gatorsmile <gatorsmile@gmail.com> Signed-off-by: gatorsmile <gatorsmile@gmail.com>
## What changes were proposed in this pull request? This PR is a follow-up of the PR apache#17899. It is to add the rule TransposeWindow the optimizer batch. ## How was this patch tested? The existing tests. Closesapache#23222 from gatorsmile/followupSPARK-20636. Authored-by: gatorsmile <gatorsmile@gmail.com> Signed-off-by: gatorsmile <gatorsmile@gmail.com>
What changes were proposed in this pull request?
Add new optimization rule to eliminate unnecessary shuffling by flipping adjacent Window expressions.
How was this patch tested?
Tested with unit tests, integration tests, and manual tests.