cloud-fan commented on code in PR #41347:
URL: https://github.com/apache/spark/pull/41347#discussion_r1267491713


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/DeduplicateRelations.scala:
##########
@@ -95,59 +102,124 @@ object DeduplicateRelations extends Rule[LogicalPlan] {
     case p: LogicalPlan if p.isStreaming => (plan, false)
 
     case m: MultiInstanceRelation =>
-      val planWrapper = RelationWrapper(m.getClass, m.output.map(_.exprId.id))
-      if (existingRelations.contains(planWrapper)) {
-        val newNode = m.newInstance()
-        newNode.copyTagsFrom(m)
-        (newNode, true)
-      } else {
-        existingRelations.add(planWrapper)
-        (m, false)
-      }
+      deduplicateAndRenew(existingRelations, 
m)(_.output.map(_.exprId.id))(node =>
+        node.newInstance().asInstanceOf[LogicalPlan with 
MultiInstanceRelation])
+
+    case p: Project =>
+      deduplicateAndRenew(existingRelations, p)(newProject => 
findAliases(newProject.projectList)
+        .map(_.exprId.id).toSeq)(newProject => 
newProject.copy(newAliases(newProject.projectList)))

Review Comment:
   nit: I'd rather define `deduplicateAndRenew` normally instead of curry, so 
that the caller can be clearer
   ```
   deduplicateAndRenew(
     existingRelations,
     p,
     newProject => findAliases(newProject.projectList).map(_.exprId.id).toSeq,
     newProject => newProject.copy(newAliases(newProject.projectList))
   )
   ```



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