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


##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala:
##########
@@ -1249,6 +1249,48 @@ class FilterPushdownSuite extends PlanTest {
     comparePlans(PushPredicateThroughJoin(originalQuery.analyze), 
correctAnswer)
   }
 
+  test("SPARK-62091: joins: do not push a condition that can fail ahead of a 
throwable " +
+    "condition of an inner join") {
+    // The divisions are built in ANSI mode, where they can fail. An inner 
join evaluates its
+    // condition before the filter above it, so after the throwable conjunct 
of the join
+    // condition, a filter condition that can fail stays above the join, 
whichever sides it
+    // reads. A condition that can not fail is pushed, or moved into the join 
condition.
+    def divide(l: Expression, r: Expression): Expression =
+      Divide(l, r, NumericEvalContext(EvalMode.ANSI))
+    val throwing = IsNull(RaiseError(Literal("boom")))
+    val originalQuery = testRelation
+      .join(testRelation1, condition = Some($"a" === $"d" && throwing))

Review Comment:
   Good catch. Thanks. In f13be04d2dd, the case runs for both `Inner` and 
`Cross`, with `joinType` passed to the join in both plans. It passes, and it 
fails with `joinType == Inner` instead of `joinType.isInstanceOf[InnerLike]`.
   



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