Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/12705#discussion_r61134222
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -1405,6 +1405,27 @@ object ReplaceIntersectWithSemiJoin extends 
Rule[LogicalPlan] {
     }
     
     /**
    +  * Replaces logical [[Except]] operator with a left-anti [[Join]] 
operator.
    +  * {{{
    +  *   SELECT a1, a2 FROM Tab1 EXCEPT SELECT b1, b2 FROM Tab2
    +  *   ==>  SELECT DISTINCT a1, a2 FROM Tab1 LEFT ANTI JOIN Tab2 ON a1<=>b1 
AND a2<=>b2
    +  * }}}
    +  *
    +  * Note:
    +  * 1. This rule is only applicable to EXCEPT DISTINCT. Do not use it for 
INTERSECT ALL.
    +  * 2. This rule has to be done after de-duplicating the attributes; 
otherwise, the generated
    +  *    join conditions will be incorrect.
    +  */
    +object ReplaceIntersectWithAntiJoin extends Rule[LogicalPlan] {
    +  def apply(plan: LogicalPlan): LogicalPlan = plan transform {
    +    case Except(left, right) =>
    +      assert(left.output.size == right.output.size)
    +      val joinCond = left.output.zip(right.output).map { case (l, r) => 
EqualNullSafe(l, r) }
    --- End diff --
    
    Could you tell me how the physical plan will turn out? It seems like this 
could be planned as a BNL, which is kinda bad.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to