Github user gatorsmile commented on the pull request:
https://github.com/apache/spark/pull/10566#issuecomment-188663070
First, will add test cases to `OuterJoinEliminationSuite` tomorrow.
Second, the current fix does not cover all the possible cases. I need to
get the inputs from you about the issues this PR is facing:
```scala
val df = Seq((1, 2, "1"), (3, 4, "3")).toDF("int", "int2",
"str").as("a")
val df2 = Seq((1, 2, "1"), (5, 6, "5")).toDF("int", "int2",
"str").as("b")
val df3 = Seq((1, 3, "1"), (4, 6, "5")).toDF("int", "int2",
"str").as("c")
// Full -> Left
val full2Left = df.join(df2, $"a.int" === $"b.int", "full")
.join(df3, $"c.int" === $"a.int", "right").select($"a.*", $"b.*",
$"c.*")
```
In the above case, the parent join condition `$"c.int" === $"a.int"` is not
eligible for the current two ways we are using to decide if the predicates are
null filtering.
1. The first way is based on the constraints. If the parent join is full
outer, the parent join will not have any IsNotNull constraint. In the current
constraint propagation, its constraints is `Set.empty[Expression]`. Thus,
`$"c.int" === $"a.int"` is not eligible for using the first way.
2. The second way is based on the run-time evaluation, `canFilterOutNull`.
This requires that all the attributes are from the same side. In the predicate
`$"c.int" === $"a.int"`, `$"a.int"` is from the left side, but `$"c.int"` is
not from the left side. (Actually, `$"c.int"` is from the other side in the
parent join.) Thus, it is not eligible for the second way too.
However, the parent join condition `$"c.int" === $"a.int"` is very common
in the join condition. We definitely can use such predicates as null-filtering
predicates. Maybe we can keep the original way as the third way, as shown in
the following link:
https://github.com/gatorsmile/spark/blob/d6a6e9cc31b0f7547b35cf25884135ea65b03676/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala#L798-L799
Does that look good to you? Thanks! : )
---
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]