wangyum opened a new pull request #33603:
URL: https://github.com/apache/spark/pull/33603
### What changes were proposed in this pull request?
Collapse repartitions if there is a project between them. For example:
```scala
sql("SELECT a FROM (SELECT id AS a, id AS b FROM range(10) DISTRIBUTE BY a,
b) t DISTRIBUTE BY a").explain(true)
```
Before this pr:
```
== Physical Plan ==
AdaptiveSparkPlan isFinalPlan=false
+- Exchange hashpartitioning(a#0L, 5), REPARTITION_BY_COL, [id=#18]
+- Project [a#0L]
+- Exchange hashpartitioning(a#0L, b#1L, 5), REPARTITION_BY_COL,
[id=#16]
+- Project [id#2L AS a#0L, id#2L AS b#1L]
+- Range (0, 10, step=1, splits=2)
```
After this pr:
```
== Physical Plan ==
AdaptiveSparkPlan isFinalPlan=false
+- Exchange hashpartitioning(a#0L, 5), REPARTITION_BY_COL, [id=#10]
+- Project [id#2L AS a#0L]
+- Range (0, 10, step=1, splits=2)
```
### Why are the changes needed?
Reduce shuffle to improve query performance.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Unit test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]