manuzhang opened a new pull request #28954:
URL: https://github.com/apache/spark/pull/28954


   ### What changes were proposed in this pull request?
   As suggested by @cloud-fan in 
https://github.com/apache/spark/pull/28916#issuecomment-651527077, apply 
`CoalesceShufflePartitions` with partitionSpecs of `Nil` when 
`ShuffleQueryStageExec#mapStats` is None.
   
   ### Why are the changes needed?
   
   For SQL like
   
   ```
   SELECT b, COUNT(t1.a) as cnt
   FROM t1
   INNER JOIN t2
   ON t1.id = t2.id
   WHERE t1.id > 10
   GROUP BY b
   ```
   
   when all ids of t1 are smaller than 10. Many unnecessary tasks are launched 
for the final shuffle stage because `CoalesceShufflePartitions` is skipped when 
input RDD has 0 partitions.
   
   #### Before 
   
![image](https://user-images.githubusercontent.com/1191767/86123007-5565f100-bb0b-11ea-991b-170e1b0bd404.png)
   
   #### After
   
![image](https://user-images.githubusercontent.com/1191767/86123148-978f3280-bb0b-11ea-87e4-1290456e45a2.png)
   
   
   ### Does this PR introduce _any_ user-facing change?
   No
   
   ### How was this patch tested?
   Updated tests.
   


----------------------------------------------------------------
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]

Reply via email to