cloud-fan commented on PR #58403:
URL: https://github.com/apache/spark/pull/58403#issuecomment-7031246335
Hi @holdenk, I'd like to revert this from master, branch-4.x and branch-4.4,
and re-land it after a review. It is not in any release yet. Two reasons:
**1. It was merged without a review.** The PR left draft on 2026-09-25 and
was merged about 26 hours later with no approving review. The only review is a
COMMENTED one from 2026-09-09, made while it was still a draft. Its question
about non-deterministic conditions got a code change ("Keep non-deterministic
conditions out of the split") but no reply on the thread. This is a non-trivial
optimizer change, and the committer guide asks that [all contributions be
reviewed before
merging](https://spark.apache.org/committers.html#review-process).
**2. It can return wrong results with a non-deterministic filter
condition.** The split keeps such a condition in the top filter. But on the
next optimizer iteration, `PushPredicateThroughNonJoin` pushes it below the top
`Project`, because the alias it reads is now computed in a lower layer and so
looks cheap. It then runs ahead of a condition written before it. On master
(b5c5fe50531):
```scala
val f = udf((i: Long) => i)
val g = udf((i: Long) => i)
spark.range(0, 10, 1, 1)
.select($"id", f($"id") as "f", g($"id") as "g")
.where($"f" > 2 && $"g" > 5 && (monotonically_increasing_id() < 3 || $"f"
> 100))
```
With `spark.sql.optimizer.splitProjectionForExpensiveFilters=false` this
returns 6, 7, 8. With the default `true` it returns no rows, with whole-stage
codegen on or off:
```
Filter (g#6L > 5)
+- Project [id#0L, f#3L, UDF(id#0L) AS g#6L]
+- Filter ((monotonically_increasing_id() < 3) OR (f#3L > 100))
+- Filter (f#3L > 2)
+- Project [id#0L, UDF(id#0L) AS f#3L]
+- Range (0, 10, step=1, splits=Some(1))
```
The reorder itself is older than this PR. The cheap/expensive partition from
SPARK-47672 can also push a non-deterministic conjunct ahead of an expensive
one written before it (`.select($"id", g($"id") as "g").where($"g" > 5 &&
monotonically_increasing_id() < 3)` returns no rows on master with the split
off), and that needs its own JIRA. This PR's split makes the reorder reachable
for exactly the conditions it means to keep above the projection.
A plain `git revert` no longer applies because SPARK-60602, SPARK-60632 and
SPARK-60885 build on this code, so the revert needs some hand-resolution. I'm
happy to open it.
cc @viirya @HyukjinKwon @dongjoon-hyun
--
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]