viirya commented on code in PR #60631:
URL: https://github.com/apache/spark/pull/60631#discussion_r4606127243
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -2631,10 +2631,14 @@ object CombineFilters extends Rule[LogicalPlan] with
PredicateHelper {
// Combining a condition written after a non-deterministic or throwable
one evaluates it ahead
// of that one, so it must also be unable to fail. `throwable` does not
report e.g. a division
// by zero in ANSI mode, which the condition before it may have kept from
being evaluated.
+ // Nor may it read a column that can fail (see `failableOutput`).
case Filter(fc, nf @ Filter(nc, grandChild)) if nc.deterministic =>
val (leading, following) =
splitConjunctivePredicates(fc).span(p => p.deterministic &&
!p.throwable)
- val (cannotFail, rest) =
following.partition(ExprUtils.canEvaluateUnconditionally)
+ lazy val failable = failableOutput(grandChild)
Review Comment:
Thanks, extending the helper for both callers separately makes sense.
On pruning, though, the dropped pruning did ship. v4.3.0's `CombineFilters`
still uses `partition`, so every release since SPARK-35273 combines `d = ...`
from `rand() < 0.01 AND d = ...` and prunes by it. SPARK-60980's description
notes it keeps exactly that. It's this PR that drops it when `d` is a failable
alias, like a view's `CAST(dt AS DATE) AS d`. I'm fine without a flag. Could
the user-facing section say that such a query no longer prunes partitions by
`dt`, as SPARK-60980's description did for `upper(p) = '1'`?
--
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]