Github user nsyca commented on a diff in the pull request:
https://github.com/apache/spark/pull/16026#discussion_r89830125
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
@@ -932,7 +932,7 @@ object PushPredicateThroughJoin extends
Rule[LogicalPlan] with PredicateHelper {
split(joinCondition.map(splitConjunctivePredicates).getOrElse(Nil), left, right)
joinType match {
- case _: InnerLike | LeftExistence(_) =>
+ case _: InnerLike | LeftSemi | ExistenceJoin(_) =>
--- End diff --
The semantics of `ExistenceJoin` says we need to preserve all the rows from
the left table through the join operation as if it is a regular `LeftOuter`
join. The `ExistenceJoin` augments the `LeftOuter` operation with a new column
called exists, set to true when the join condition in the ON clause is true and
false otherwise. The filter of any rows will happen in the Filter operation
above the `ExistenceJoin`.
Example:
A(c1, c2):
{ (1, 1), (1, 2) }
B(c1):
{ (NULL) }
// can be any value as it is irrelevant in this example
````
select A.*
from A
where exists (select 1 from B where A.c1 = A.c2)
or A.c2=2
````
In this example, the correct result is all the rows from A. If the pattern
`ExistenceJoin` at line 935 in `Optimizer.scala` added by the PR of this JIRA
is indeed active, the code will push down the predicate `A.c1 = A.c2` to be a
Filter on relation A, which will filter the row (1,2) from A.
---
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]