sarutak commented on code in PR #60725:
URL: https://github.com/apache/spark/pull/60725#discussion_r4641056520
##########
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:
Nit: `afterBarrier` checks `InnerLike`, so it also covers a `Cross` join
with a condition, which `df.join(other, cond, "cross")` and `CROSS JOIN ... ON`
produce. Neither `FilterPushdownSuite` nor the new `DataFrameSuite` cases pin
that: with `joinType == Inner` instead of `joinType.isInstanceOf[InnerLike]`,
they still pass, while Issue 2 written with `CROSS JOIN` then fails with
`DIVIDE_BY_ZERO`. Could this case run for both, e.g. `Seq(Inner, Cross).foreach
{ joinType => ... }`, with `joinType` passed to the join in both
`originalQuery` and `correctAnswer`? I tried that locally: it passes, and fails
with `joinType == Inner`.
--
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]