tanelk commented on a change in pull request #31045:
URL: https://github.com/apache/spark/pull/31045#discussion_r552866614
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -1612,9 +1612,12 @@ object ConvertToLocalRelation extends Rule[LogicalPlan] {
* {{{
* SELECT DISTINCT f1, f2 FROM t ==> SELECT f1, f2 FROM t GROUP BY f1, f2
* }}}
+ *
+ * The [[Distinct]] can be ignored if it is the right child of a left semi or
anti join.
*/
object ReplaceDistinctWithAggregate extends Rule[LogicalPlan] {
- def apply(plan: LogicalPlan): LogicalPlan = plan transform {
+ def apply(plan: LogicalPlan): LogicalPlan = plan transformDown {
+ case j @ Join(_, Distinct(right), LeftSemiOrAnti(_), _, _) => j.copy(right
= right)
Review comment:
I benchmarked a bit and you are right - this can cause a performance
regression. For example q87 took a 10% hit on sf100. I think it's best to close
this PR and issue.
----------------------------------------------------------------
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]