dongjoon-hyun commented on code in PR #60572:
URL: https://github.com/apache/spark/pull/60572#discussion_r4594801427


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala:
##########
@@ -848,9 +848,10 @@ case class Join(
     patterns
   }
 
-  // Ignore hint for canonicalization
+  // Ignore hint for canonicalization, and normalize the join type, see 
`JoinType.canonicalized`.
   protected override def doCanonicalize(): LogicalPlan =
-    super.doCanonicalize().asInstanceOf[Join].copy(hint = JoinHint.NONE)
+    super.doCanonicalize().asInstanceOf[Join].copy(
+      joinType = joinType.canonicalized, hint = JoinHint.NONE)

Review Comment:
   Thank you for the review. Confirmed: `PlanMerger.tryMergePlans` compared the 
raw join types, so two existence joins that differ below the join (for example 
`max(x)` and `sum(y)` of the same table under the same `x > 50 OR EXISTS 
(...)`) were not merged, while the same pair without the `EXISTS` was.
   
   I applied the suggestion in 9793214. The Join case now compares 
`joinType.canonicalized`, and for two existence joins it maps the new plan's 
`exists` to the cached plan's, since the merged join keeps the cached join 
type. I added two tests to `MergeSubplansSuite`: the merge, and no merge when 
the join conditions differ. The first one fails without the change.
   



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