LantaoJin opened a new pull request #29120:
URL: https://github.com/apache/spark/pull/29120
### What changes were proposed in this pull request?
Coalesce should not reduce the child parallelism if it contains a Join.
Add a new optimizer rule `RepartitionForCoalesceWithJoin` to add a
Repartition if the child of Coalesce contains a Join.
### Why are the changes needed?
How to reproduce this issue:
```
spark.range(100).createTempView("t1")
spark.range(200).createTempView("t2")
spark.sql("set spark.sql.autoBroadcastJoinThreshold=0")
spark.sql("select /*+ COALESCE(1) */ t1.* from t1 join t2 on (t1.id =
t2.id)").show
```
Before

The number of partitions of SortMergeJoin is 1
After

The number of partitions of SortMergeJoin is 5.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Add a 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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]