maropu commented on a change in pull request #31656:
URL: https://github.com/apache/spark/pull/31656#discussion_r584017423
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -526,21 +527,29 @@ object RemoveNoopUnion extends Rule[LogicalPlan] {
case _ => plan
}
- private def removeUnion(u: Union): Option[LogicalPlan] = {
- val unionChildren = u.children.map(removeAliasOnlyProject)
- if (unionChildren.tail.forall(unionChildren.head.sameResult(_))) {
- Some(u.children.head)
+ private def simplifyUnion(u: Union): LogicalPlan = {
+ val uniqueChildren = mutable.ArrayBuffer.empty[LogicalPlan]
+ val uniqueChildrenKey = mutable.HashSet.empty[LogicalPlan]
+
+ u.children.foreach { c =>
+ val key = removeAliasOnlyProject(c).canonicalized
Review comment:
We need plan canonicalization here? It looks enough to check if the
output is the same just like `LogicalPlan.sameOutput`?
----------------------------------------------------------------
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]