cloud-fan commented on a change in pull request #29104:
URL: https://github.com/apache/spark/pull/29104#discussion_r460646928
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/planning/patterns.scala
##########
@@ -388,3 +390,37 @@ object PhysicalWindow {
case _ => None
}
}
+
+object ExtractSingleColumnNullAwareAntiJoin extends JoinSelectionHelper with
PredicateHelper {
+
+ // TODO support multi column NULL-aware anti join in future.
+ // See. http://www.vldb.org/pvldb/vol2/vldb09-423.pdf Section 6
+ // multi-column null aware anti join is much more complicated than single
column ones.
+
+ // streamedSideKeys, buildSideKeys
+ private type ReturnType = (Seq[Expression], Seq[Expression])
+
+ /**
+ * See. [SPARK-32290]
+ * LeftAnti(condition: Or(EqualTo(a=b), IsNull(EqualTo(a=b)))
+ * will almost certainly be planned as a Broadcast Nested Loop join,
+ * which is very time consuming because it's an O(M*N) calculation.
+ * But if it's a single column case, and buildSide data is small enough,
+ * O(M*N) calculation could be optimized into O(M) using hash lookup instead
of loop lookup.
+ */
+ def unapply(join: Join): Option[ReturnType] = join match {
+ case Join(left, right, LeftAnti,
+ Some(Or(EqualTo(leftAttr: AttributeReference, rightAttr:
AttributeReference),
+ IsNull(EqualTo(tmpLeft: AttributeReference, tmpRight:
AttributeReference)))), _)
Review comment:
how about
```
Some(Or(e @ EqualTo(leftAttr: AttributeReference, rightAttr:
AttributeReference),
IsNull(e2: EqualTo) if ... && e.semanticEquals(e2)
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]