Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/14012#discussion_r69522366
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
 ---
    @@ -1106,12 +1106,15 @@ object PushDownPredicate extends Rule[LogicalPlan] 
with PredicateHelper {
         // Push [[Filter]] operators through [[Window]] operators. Parts of 
the predicate that can be
         // pushed beneath must satisfy the following two conditions:
         // 1. All the expressions are part of window partitioning key. The 
expressions can be compound.
    -    // 2. Deterministic
    +    // 2. Deterministic.
    +    // 3. Placed before any non-deterministic predicates.
         case filter @ Filter(condition, w: Window)
             if w.partitionSpec.forall(_.isInstanceOf[AttributeReference]) =>
           val partitionAttrs = 
AttributeSet(w.partitionSpec.flatMap(_.references))
    +      var isPredicatePushdownAble = true
           val (pushDown, stayUp) = 
splitConjunctivePredicates(condition).partition { cond =>
    -        cond.references.subsetOf(partitionAttrs) && cond.deterministic &&
    +        isPredicatePushdownAble = isPredicatePushdownAble && 
cond.deterministic
    +        isPredicatePushdownAble && 
cond.references.subsetOf(partitionAttrs) &&
    --- End diff --
    
    The following can be easier to read:
    
    ```scala
    val (candidates, containingNonDeterministic) =
      splitConjunctivePredicates(condition).span(_.deterministic)
    
    val (pushDown, rest) = candidates.partition { cond =>
      cond.references.subsetOf(partitionAttrs) && 
partitionAttrs.forall(_.isInstanceOf[Attribute])
    }
    
    val stayUp = rest ++ containingNonDeterministic
    ```



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to