Github user hvanhovell commented on a diff in the pull request:
https://github.com/apache/spark/pull/12705#discussion_r61134754
--- 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] {
--- End diff --
We could also integrate this with `ReplaceIntersectWithSemiJoin`. But I'll
leave that up to you.
---
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]