wangyum commented on code in PR #36921:
URL: https://github.com/apache/spark/pull/36921#discussion_r901327809


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala:
##########
@@ -1728,6 +1740,16 @@ object PushPredicateThroughNonJoin extends 
Rule[LogicalPlan] with PredicateHelpe
       case _ => false
     }
   }
+
+  /**
+   * Do not push complex predicate for these LogicalPlan to reduce complex 
expression evaluation.
+   */
+  private def doNotPushComplexPredicate(plan: LogicalPlan): Boolean = plan 
match {
+    case _: LeafNode => true
+    case _: Filter => true
+    case _: Project => true
+    case _ => false

Review Comment:
   Should not include `Join`. For example:
   ```scala
   spark.sql("create table t1(a int, b string) using parquet")
   spark.sql("create table t2(x int, y string) using parquet")
   
   spark.sql("select * from (select b + 1 as new_b, * from (select * from t1 
right join t2 on a = x) t ) where new_b > 1").explain(true)
   ```
   
   If push down:
   ```
   == Optimized Logical Plan ==
   Project [(cast(b#2 as double) + 1.0) AS new_b#0, a#1, b#2, x#3, y#4]
   +- Join Inner, (a#1 = x#3)
      :- Filter ((isnotnull(b#2) AND ((cast(b#2 as double) + 1.0) > 1.0)) AND 
isnotnull(a#1))
      :  +- Relation default.t1[a#1,b#2] parquet
      +- Filter isnotnull(x#3)
         +- Relation default.t2[x#3,y#4] parquet
   ```
   
   If do not push down:
   ```
   == Optimized Logical Plan ==
   Filter (isnotnull(new_b#0) AND (new_b#0 > 1.0))
   +- Project [(cast(b#2 as double) + 1.0) AS new_b#0, a#1, b#2, x#3, y#4]
      +- Join RightOuter, (a#1 = x#3)
         :- Filter isnotnull(a#1)
         :  +- Relation default.t1[a#1,b#2] parquet
         +- Relation default.t2[x#3,y#4] parquet
   ```
   



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