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


   ### What changes were proposed in this pull request?
   
   This pr add new rule to removes outer join if it only has distinct on 
streamed side. For example:
   ```scala
   spark.range(200L).selectExpr("id AS a").createTempView("t1")
   spark.range(300L).selectExpr("id AS b").createTempView("t2")
   spark.sql("SELECT DISTINCT a FROM t1 LEFT JOIN t2 ON a = b").explain(true)
   ```
   
   Before this pr:
   ```
   == Optimized Logical Plan ==
   Aggregate [a#2L], [a#2L]
   +- Project [a#2L]
      +- Join LeftOuter, (a#2L = b#6L)
         :- Project [id#0L AS a#2L]
         :  +- Range (0, 200, step=1, splits=Some(2))
         +- Project [id#4L AS b#6L]
            +- Range (0, 300, step=1, splits=Some(2))
   ```
   
   After this pr:
   ```
   == Optimized Logical Plan ==
   Aggregate [a#2L], [a#2L]
   +- Project [id#0L AS a#2L]
      +- Range (0, 200, step=1, splits=Some(2))
   ```
   
   ### 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.

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