dongjoon-hyun commented on code in PR #60725:
URL: https://github.com/apache/spark/pull/60725#discussion_r4639300925


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -3428,8 +3428,13 @@ object PushPredicateThroughJoin extends 
Rule[LogicalPlan] with PredicateHelper {
     // push the where condition down into join filter
     case f @ Filter(filterCondition, Join(left, right, joinType, 
joinCondition, hint))
         if canPushThrough(joinType) =>
-      val (movable, stayUp) =
-        splitMovable(splitConjunctivePredicates(filterCondition), Seq(left, 
right))
+      // An inner join evaluates its condition before the filter, so the 
filter's conditions are
+      // written after it, as at the end of its ON clause, and a 
non-deterministic or throwable
+      // conjunct of it keeps the ones that can fail in place.
+      val afterBarrier = joinType.isInstanceOf[InnerLike] &&
+        joinCondition.exists(cond => !cond.deterministic || cond.throwable)

Review Comment:
   Thank you, @sarutak. I included left semi and left anti joins in this PR in 
8c858aa7a61: `afterBarrier` is now set for `InnerLike`, `LeftSemi` and 
`LeftAnti` joins whose condition has a non-deterministic or throwable conjunct. 
I kept the check inline, since this PR has a single call site. The new 
`FilterPushdownSuite` case covers left semi, left anti and left outer joins 
with the same throwable condition. Over the left outer join, both conjuncts are 
still pushed, so the case fails without the join type check. I did not add a 
right outer case, since it takes the same branch as the left outer one. 
`DataFrameSuite` also has a case for left semi and left anti joins now. The 
comment, the title and the description cover them too.
   



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/predicates.scala:
##########
@@ -299,11 +299,20 @@ trait PredicateHelper extends AliasHelper with Logging {
    * inputs of the joins or of the filter below, that can fail (see
    * `failableOutput`). It would be evaluated on rows that the conjunct before 
it may have
    * dropped. The conjuncts that may not move are returned in their written 
order.
+   *
+   * If `afterBarrier` is true, the conjuncts are evaluated after a condition 
that they may not
+   * move ahead of, as if after a non-deterministic or throwable conjunct, so 
only the ones that
+   * can not fail may move.

Review Comment:
   Thanks. I rephrased it in 8c858aa7a61: "If `afterBarrier` is true, the 
conjuncts are treated as written after a conjunct outside `conditions` that 
keeps the ones that can fail in place, such as a throwable one in the condition 
of the join below them, so only the ones that can not fail may move."
   



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to