Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/7191#discussion_r35708458
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
---
@@ -554,27 +554,33 @@ object PushPredicateThroughProject extends
Rule[LogicalPlan] with PredicateHelpe
// Split the condition into small conditions by `And`, so that we
can push down part of this
// condition without nondeterministic expressions.
val andConditions = splitConjunctivePredicates(condition)
-
- val (deterministic, nondeterministic) =
andConditions.partition(_.collect {
- case a: Attribute if aliasMap.contains(a) => aliasMap(a)
- }.forall(_.deterministic))
+ val nondeterministicConditions =
andConditions.filter(hasNondeterministic(_, aliasMap))
// If there is no nondeterministic conditions, push down the whole
condition.
- if (nondeterministic.isEmpty) {
+ if (nondeterministicConditions.isEmpty) {
project.copy(child = Filter(replaceAlias(condition, aliasMap),
grandChild))
} else {
// If they are all nondeterministic conditions, leave it
un-changed.
- if (deterministic.isEmpty) {
+ if (nondeterministicConditions.length == andConditions.length) {
--- End diff --
Consider just making this an `else if` instead of nesting.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]