dongjoon-hyun commented on code in PR #60646:
URL: https://github.com/apache/spark/pull/60646#discussion_r4608550603
##########
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/optimizer/FilterPushdownSuite.scala:
##########
@@ -1203,6 +1203,26 @@ class FilterPushdownSuite extends PlanTest {
comparePlans(optimized, originalQuery)
}
+ test("SPARK-61924: joins: do not push a condition that can fail ahead of a "
+
+ "non-deterministic one") {
+ // The divisions are built in ANSI mode, where they can fail, and so can
`q` and `p`, which
+ // they compute. After `rand(0) > 0.1`, a condition that can fail by
itself or reads `q` or `p`
+ // stays above the join, while one over `a`, which can not fail, is
pushed. So is a division
+ // written before `rand(0) > 0.1`.
+ def divide(l: Expression, r: Expression): Expression =
+ Divide(l, r, NumericEvalContext(EvalMode.ANSI))
+ val left = testRelation.select($"a", $"b", divide($"a", $"b").as("q"))
+ val right = testRelation1.select($"d", divide($"d", Literal(2)).as("p"))
+ val originalQuery = left.join(right).where(divide($"a", $"b") > 1 &&
Rand(0) > 0.1 &&
Review Comment:
For the migration guide, I'd like to keep this PR without an entry, as
SPARK-60980 and SPARK-60633 did for the same kind of change. The PR description
already lists this change in the user-facing section: a conjunct written before
the non-deterministic one, or in the `ON` clause, still becomes the join
condition.
--
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]