LuciferYang commented on a change in pull request #35694:
URL: https://github.com/apache/spark/pull/35694#discussion_r823431908



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala
##########
@@ -1690,11 +1690,10 @@ object PushPredicateThroughNonJoin extends 
Rule[LogicalPlan] with PredicateHelpe
    */
   private def canPushThroughCondition(plan: LogicalPlan, condition: 
Expression): Boolean = {
     val attributes = plan.outputSet
-    val matched = condition.find {
-      case s: SubqueryExpression => 
s.plan.outputSet.intersect(attributes).nonEmpty
-      case _ => false
+    condition.exists {

Review comment:
       This is how I derived this, the original logic same as:
   
   ```scala
   condition.find {
     case s: SubqueryExpression => 
s.plan.outputSet.intersect(attributes).nonEmpty
     case _ => false
   }.isEmpty
   ```
   It is equivalent to
   
   ```scala
   !condition.find {
     case s: SubqueryExpression => 
s.plan.outputSet.intersect(attributes).nonEmpty
     case _ => false
   }.noEmpty
   ```
   
   -->
   
   ```scala
   !condition.exists {
     case s: SubqueryExpression => 
s.plan.outputSet.intersect(attributes).nonEmpty
     case _ => false
   }
   ```
   
   ->
   ```
   condition.exists {
     case s: SubqueryExpression => 
!s.plan.outputSet.intersect(attributes).nonEmpty
     case _ => !false
   }
   ```
   
   ->
   ```
   condition.exists {
     case s: SubqueryExpression => 
s.plan.outputSet.intersect(attributes).isEmpty
     case _ => true
   }
   ```




-- 
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]

Reply via email to