Hisoka-X commented on code in PR #41554:
URL: https://github.com/apache/spark/pull/41554#discussion_r1278971340
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala:
##########
@@ -220,7 +220,52 @@ object DeduplicateRelations extends Rule[LogicalPlan] {
if (attrMap.isEmpty) {
planWithNewChildren
} else {
- planWithNewChildren.rewriteAttrs(attrMap)
+ def rewriteAttrsMatchWithSubPlan(
+ attrs: Seq[Attribute],
+ attrMap: AttributeMap[Attribute],
+ planOutput: Seq[Attribute]): Seq[Attribute] = {
+ val canRewriteAttrs = attrMap.filter(a =>
planOutput.contains(a._2))
+ attrs.map(attr => canRewriteAttrs.getOrElse(attr, attr))
+ }
+
+ def rewriteOrderMatchWithSubPlan(
+ attrs: Seq[SortOrder],
+ attrMap: AttributeMap[Attribute],
+ planOutput: Seq[Attribute]): Seq[SortOrder] = {
+ val canRewriteAttrs = attrMap.filter(a =>
planOutput.contains(a._2))
+ attrs.filter(_.child.isInstanceOf[Attribute]).map(attr => {
+ if
(canRewriteAttrs.contains(attr.child.asInstanceOf[Attribute])) {
+ attr.copy(child =
canRewriteAttrs(attr.child.asInstanceOf[Attribute]))
+ } else {
+ attr
+ }
+ })
+ }
+
+ planWithNewChildren match {
+ case c @ CoGroup(_, keyDeserializer, leftDeserializer,
rightDeserializer,
+ leftGroup, rightGroup, leftAttr, rightAttr, leftOrder,
rightOrder, _, left,
Review Comment:
Dpme
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala:
##########
@@ -220,7 +220,52 @@ object DeduplicateRelations extends Rule[LogicalPlan] {
if (attrMap.isEmpty) {
planWithNewChildren
} else {
- planWithNewChildren.rewriteAttrs(attrMap)
+ def rewriteAttrsMatchWithSubPlan(
+ attrs: Seq[Attribute],
+ attrMap: AttributeMap[Attribute],
+ planOutput: Seq[Attribute]): Seq[Attribute] = {
+ val canRewriteAttrs = attrMap.filter(a =>
planOutput.contains(a._2))
+ attrs.map(attr => canRewriteAttrs.getOrElse(attr, attr))
+ }
+
+ def rewriteOrderMatchWithSubPlan(
+ attrs: Seq[SortOrder],
+ attrMap: AttributeMap[Attribute],
+ planOutput: Seq[Attribute]): Seq[SortOrder] = {
+ val canRewriteAttrs = attrMap.filter(a =>
planOutput.contains(a._2))
+ attrs.filter(_.child.isInstanceOf[Attribute]).map(attr => {
+ if
(canRewriteAttrs.contains(attr.child.asInstanceOf[Attribute])) {
+ attr.copy(child =
canRewriteAttrs(attr.child.asInstanceOf[Attribute]))
+ } else {
+ attr
+ }
+ })
+ }
+
+ planWithNewChildren match {
+ case c @ CoGroup(_, keyDeserializer, leftDeserializer,
rightDeserializer,
+ leftGroup, rightGroup, leftAttr, rightAttr, leftOrder,
rightOrder, _, left,
Review Comment:
Done
--
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]