cloud-fan commented on code in PR #41347:
URL: https://github.com/apache/spark/pull/41347#discussion_r1263172474
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala:
##########
@@ -117,37 +311,49 @@ object DeduplicateRelations extends Rule[LogicalPlan] {
}
}
- val planWithNewSubquery = plan.transformExpressions {
- case subquery: SubqueryExpression =>
- val (renewed, changed) =
renewDuplicatedRelations(existingRelations, subquery.plan)
- if (changed) planChanged = true
- subquery.withNewPlan(renewed)
- }
+ val (newPlan, changed) = getNewPlanWithNewChildren(existingRelations,
newChildren.toArray,
+ plan, planChanged)
+ planChanged |= changed
+ newPlan
+ } else {
+ plan
+ }
+ (newPlan, planChanged)
+ }
- if (planChanged) {
- if (planWithNewSubquery.childrenResolved) {
- val planWithNewChildren =
planWithNewSubquery.withNewChildren(newChildren.toSeq)
- val attrMap = AttributeMap(
- plan
- .children
- .flatMap(_.output).zip(newChildren.flatMap(_.output))
- .filter { case (a1, a2) => a1.exprId != a2.exprId }
- )
- if (attrMap.isEmpty) {
- planWithNewChildren
- } else {
- planWithNewChildren.rewriteAttrs(attrMap)
- }
- } else {
- planWithNewSubquery.withNewChildren(newChildren.toSeq)
- }
- } else {
+ private def getNewPlanWithNewChildren(
Review Comment:
why is it hard? The original code can handle LogicalPlan with any number of
children, and it can definitely take care of plans that only have one child.
--
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]