cboumalh commented on code in PR #54236:
URL: https://github.com/apache/spark/pull/54236#discussion_r2799616758


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -1860,22 +1890,74 @@ object CombineUnions extends Rule[LogicalPlan] {
             if projectList.forall(_.deterministic) && children.nonEmpty &&
               flattenDistinct && byName == topByName && allowMissingCol == 
topAllowMissingCol &&
               canPushProjectionThroughUnion(project) =>
-          stack.pushAll(pushProjectionThroughUnion(projectList, u).reverse)
+          stack.pushAll(pushProjectionThroughUnionLike(projectList, u).reverse)
         case project @ Project(projectList, Deduplicate(keys: Seq[Attribute], 
u: Union))
             if projectList.forall(_.deterministic) && flattenDistinct && 
u.byName == topByName &&
               u.allowMissingCol == topAllowMissingCol && AttributeSet(keys) == 
u.outputSet &&
               canPushProjectionThroughUnion(project) =>
-          stack.pushAll(pushProjectionThroughUnion(projectList, u).reverse)
+          stack.pushAll(pushProjectionThroughUnionLike(projectList, u).reverse)
         case project @ Project(projectList, u @ Union(children, byName, 
allowMissingCol))
             if projectList.forall(_.deterministic) && children.nonEmpty && 
byName == topByName &&
               allowMissingCol == topAllowMissingCol && 
canPushProjectionThroughUnion(project) =>
-          stack.pushAll(pushProjectionThroughUnion(projectList, u).reverse)
+          stack.pushAll(pushProjectionThroughUnionLike(projectList, u).reverse)
         case child =>
           flattened += child
       }
     }
     union.copy(children = flattened.toSeq)
   }
+
+  private def flattenSequentialStreamingUnion(

Review Comment:
   nit: I noticed `flattenSequentialStreamingUnion` and `flattenUnion` share a 
lot of similarity. Was there any consideration for extracting the common logic? 
Totally fine to leave as-is if the pattern matching makes it tricky to abstract 
cleanly.



-- 
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]

Reply via email to