seanli-rallyhealth commented on a change in pull request #27436: 
[SPARK-30705][SQL] Improve CaseWhen sub-expression equality
URL: https://github.com/apache/spark/pull/27436#discussion_r375576876
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala
 ##########
 @@ -91,7 +91,18 @@ class EquivalentExpressions {
     def childrenToRecurse: Seq[Expression] = expr match {
       case _: CodegenFallback => Nil
       case i: If => i.predicate :: Nil
-      case c: CaseWhen => c.children.head :: Nil
+      case c: CaseWhen =>
+        val firstExpression = c.children.head
+        val firstUdes = firstExpression.collect { case u: 
UserDefinedExpression => u }
+        val accessedExpressions = c.children.filter { e =>
+          val udes = e.collect { case u: UserDefinedExpression => u }
+          udes.nonEmpty && firstUdes.containsSlice(udes)
+        }
+        if (accessedExpressions.nonEmpty) {
 
 Review comment:
   don't think accessedExpressions will be empty since firstExpression is 
always inside.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to