You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/06 00:04:14 UTC

[GitHub] [spark] seanli-rallyhealth commented on a change in pull request #27436: [SPARK-30705][SQL] Improve CaseWhen sub-expression equality

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:
users@infra.apache.org


With regards,
Apache Git Services

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