File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -937,10 +937,14 @@ object SimplifyConditionals extends Rule[LogicalPlan] with PredicateHelper {
937937 */
938938case class OptimizeCodegen (conf : CatalystConf ) extends Rule [LogicalPlan ] {
939939 def apply (plan : LogicalPlan ): LogicalPlan = plan transformAllExpressions {
940- case e @ CaseWhen (branches, elseBranch)
941- if branches.size + elseBranch.size <= conf.maxCaseBranchesForCodegen =>
940+ case e : CaseWhen if canCodeGen(e) =>
942941 e.toCodegen()
943942 }
943+
944+ private def canCodeGen (e : CaseWhen ): Boolean = {
945+ val numBranches = e.branches.size + e.elseValue.size
946+ numBranches <= conf.maxCaseBranchesForCodegen
947+ }
944948}
945949
946950/**
You can’t perform that action at this time.
0 commit comments