cloud-fan commented on a change in pull request #30955:
URL: https://github.com/apache/spark/pull/30955#discussion_r599729395



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -548,41 +548,68 @@ object PushFoldableIntoBranches extends Rule[LogicalPlan] 
with PredicateHelper {
     foldables.nonEmpty && others.length < 2
   }
 
+  // Not all UnaryExpression can be pushed into (if / case) branches, e.g. 
Alias.
+  private def supportedUnaryExpression(e: UnaryExpression): Boolean = e match {
+    case _: IsNull | _: IsNotNull => true
+    case _: UnaryMathExpression | _: Abs | _: Bin | _: Factorial | _: Hex => 
true
+    case _: String2StringExpression | _: Ascii | _: Base64 | _: BitLength | _: 
Chr | _: Length =>
+      true
+    case _: CastBase => true
+    case _: GetDateField | _: LastDay => true
+    case _: ExtractIntervalPart => true
+    case _: ArraySetLike => true
+    case _: ExtractValue => true
+    case _ => false
+  }
+
+  // Not all BinaryExpression can be pushed into (if / case) branches.
+  private def supportedBinaryExpression(e: BinaryExpression): Boolean = e 
match {
+    case _: BinaryComparison | _: StringPredicate | _: StringRegexExpression 
=> true
+    case _: BinaryArithmetic => true
+    case _: BinaryMathExpression => true
+    case _: AddMonths | _: DateAdd | _: DateAddInterval | _: DateDiff | _: 
DateSub => true

Review comment:
       I think so




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

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