wangyum opened a new pull request #33105:
URL: https://github.com/apache/spark/pull/33105


   ### What changes were proposed in this pull request?
   
   Enhance `OptimizeRepartition` to remove repartition if the child maximum 
number of rows less than or equal to 1. For example:
   ```scala
   spark.sql("select count(*) from range(1, 10, 2, 
2)").repartition(10).explain("cost")
   ```
   
   Before this PR:
   ```
   == Optimized Logical Plan ==
   Repartition 10, true, Statistics(sizeInBytes=16.0 B, rowCount=1)
   +- Aggregate [count(1) AS count(1)#2L], Statistics(sizeInBytes=16.0 B, 
rowCount=1)
      +- Project, Statistics(sizeInBytes=20.0 B)
         +- Range (1, 10, step=2, splits=Some(2)), Statistics(sizeInBytes=40.0 
B, rowCount=5)
   ```
   
   After this PR:
   ```
   == Optimized Logical Plan ==
   Aggregate [count(1) AS count(1)#2L], Statistics(sizeInBytes=16.0 B, 
rowCount=1)
   +- Project, Statistics(sizeInBytes=20.0 B)
      +- Range (1, 10, step=2, splits=Some(2)), Statistics(sizeInBytes=40.0 B, 
rowCount=5)
   ```
   
   ### Why are the changes needed?
   
   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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to