wangyum commented on a change in pull request #31189:
URL: https://github.com/apache/spark/pull/31189#discussion_r558037693



##########
File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/expressions.scala
##########
@@ -620,6 +620,30 @@ object PushFoldableIntoBranches extends Rule[LogicalPlan] 
with PredicateHelper {
   }
 }
 
+/**
+ * Remove duplicated case when branches.
+ */
+object RemoveDuplicatedBranches extends Rule[LogicalPlan] with PredicateHelper 
{
+
+  private def contains(branches: Seq[(Expression, Expression)], elem: 
(Expression, Expression)) = {
+    branches.exists { case (condExpr, valueExpr) =>
+      condExpr.semanticEquals(elem._1) && valueExpr.semanticEquals(elem._2)
+    }

Review comment:
       Could we support another case? ```CASE WHEN cond1 THEN values1 WHEN 
cond1 THEN values2 END``` => ```CASE WHEN cond1 THEN values1 END```.




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