ulysses-you commented on code in PR #36177:
URL: https://github.com/apache/spark/pull/36177#discussion_r851075774
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala:
##########
@@ -184,6 +202,23 @@ object EliminateOuterJoin extends Rule[LogicalPlan] with
PredicateHelper {
case a @ Aggregate(_, _, p @ Project(_, Join(_, right, RightOuter, _, _)))
if a.groupOnly && p.references.subsetOf(right.outputSet) =>
a.copy(child = p.copy(child = right))
+
+ case a @ Aggregate(_, aggExprs, Join(left, _, LeftOuter, _, _))
+ if a.references.subsetOf(left.outputSet) &&
+ allDuplicateAgnostic(aggExprs) =>
+ a.copy(child = left)
+ case a @ Aggregate(_, aggExprs, Join(_, right, RightOuter, _, _))
+ if a.references.subsetOf(right.outputSet) &&
+ allDuplicateAgnostic(aggExprs) =>
+ a.copy(child = right)
+ case a @ Aggregate(_, aggExprs, p @ Project(_, Join(left, _, LeftOuter, _,
_)))
Review Comment:
Change to `projectList.forall(_.deterministic)`, and add the test
```scala
val p1 = x.join(y, joinType, Some($"x.a" === $"y.a")).select($"$t.a" as
"a1", rand(1) as "b1")
.groupBy($"b1")($"b1", max($"a1")).analyze
comparePlans(Optimize.execute(p1), p1)
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]