-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-19601] [SQL] Fix CollapseRepartition rule to preserve shuffle-enabled Repartition #16933
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
Changes from 1 commit
7b4a9dd
7722781
f9483cb
0f95a6f
680c3af
5453ad4
4649af4
8306c49
379a15a
d69c5a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,7 @@ class CollapseRepartitionSuite extends PlanTest { | |
| } | ||
|
|
||
| test("collapse one coalesce and one repartition into one") { | ||
| // Remove useless coalesce below repartition | ||
| val query1 = testRelation | ||
| .coalesce(20) | ||
| .repartition(5) | ||
|
|
@@ -65,14 +66,26 @@ class CollapseRepartitionSuite extends PlanTest { | |
|
|
||
| comparePlans(optimized1, correctAnswer1) | ||
|
|
||
| // Remove useless coalesce above repartition when its numPartitions is larger than or equal to | ||
| // the child's numPartitions | ||
| val query2 = testRelation | ||
| .repartition(5) | ||
| .coalesce(20) | ||
|
|
||
| val optimized2 = Optimize.execute(query2.analyze) | ||
| val correctAnswer2 = testRelation.repartition(5).coalesce(20).analyze | ||
| val correctAnswer2 = testRelation.repartition(5).analyze | ||
|
|
||
| comparePlans(optimized2, correctAnswer2) | ||
|
|
||
| // Keep coalesce above repartition unchanged when its numPartitions is smaller than the child | ||
| val query3 = testRelation | ||
| .repartition(5) | ||
| .coalesce(3) | ||
|
|
||
| val optimized3 = Optimize.execute(query3.analyze) | ||
| val correctAnswer3 = testRelation.repartition(5).coalesce(3).analyze | ||
|
|
||
| comparePlans(optimized3, correctAnswer3) | ||
| } | ||
|
|
||
| test("collapse repartition and repartitionBy into one") { | ||
|
|
@@ -96,17 +109,26 @@ class CollapseRepartitionSuite extends PlanTest { | |
| } | ||
|
|
||
| test("collapse repartitionBy and repartition into one") { | ||
| val query = testRelation | ||
| val query1 = testRelation | ||
| .distribute('a)(20) | ||
| .repartition(10) | ||
|
||
|
|
||
| val optimized = Optimize.execute(query.analyze) | ||
| val correctAnswer = testRelation.distribute('a)(10).analyze | ||
| val optimized1 = Optimize.execute(query1.analyze) | ||
| val correctAnswer1 = testRelation.distribute('a)(10).analyze | ||
|
||
|
|
||
| comparePlans(optimized, correctAnswer) | ||
| comparePlans(optimized1, correctAnswer1) | ||
|
|
||
| val query2 = testRelation | ||
| .distribute('a)(20) | ||
| .repartition(30) | ||
|
|
||
| val optimized2 = Optimize.execute(query2.analyze) | ||
| val correctAnswer2 = testRelation.distribute('a)(20).analyze | ||
|
|
||
| comparePlans(optimized2, correctAnswer2) | ||
| } | ||
|
|
||
| test("do not collapse coalesce above repartitionBy into one") { | ||
| test("coalesce above repartitionBy") { | ||
| val query = testRelation | ||
| .distribute('a)(20) | ||
| .coalesce(10) | ||
|
|
||
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 can add a comment:
// Always respects the top repartition amd removes useless distribute below repartition