dongjoon-hyun commented on a change in pull request #29950:
URL: https://github.com/apache/spark/pull/29950#discussion_r522669924
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -758,6 +756,42 @@ object CollapseProject extends Rule[LogicalPlan] with
AliasHelper {
s.copy(child = p2.copy(projectList = buildCleanedProjectList(l1,
p2.projectList)))
}
+ private def collapseProjects(plan: LogicalPlan): LogicalPlan = plan match {
+ case p1 @ Project(_, p2: Project) =>
+ if (haveCommonNonDeterministicOutput(p1.projectList, p2.projectList) ||
+ moreThanMaxAllowedCommonOutput(p1.projectList, p2.projectList)) {
+ p1
+ } else {
+ collapseProjects(
+ p2.copy(projectList = buildCleanedProjectList(p1.projectList,
p2.projectList)))
+ }
+ case _ => plan
+ }
+
+ private def collectAliases(projectList: Seq[NamedExpression]):
AttributeMap[Alias] = {
+ AttributeMap(projectList.collect {
+ case a: Alias => a.toAttribute -> a
+ })
+ }
+
+ // Whether the largest times common outputs from lower operator used in
upper operators is
+ // larger than allowed.
Review comment:
`than allowed` -> `than the maximum`?
----------------------------------------------------------------
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]