File tree Expand file tree Collapse file tree 2 files changed +6
-0
lines changed
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions Expand file tree Collapse file tree 2 files changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ class EquivalentExpressions {
7373 // 1. CodegenFallback: it's children will not be used to generate code (call eval() instead)
7474 // 2. ReferenceToExpressions: it's kind of an explicit sub-expression elimination.
7575 val shouldRecurse = root match {
76+ // TODO: some expressions implements `CodegenFallback` but can still do codegen,
77+ // e.g. `CaseWhen`, we should support them.
7678 case _ : CodegenFallback => false
7779 case _ : ReferenceToExpressions => false
7880 case _ => true
Original file line number Diff line number Diff line change @@ -110,12 +110,16 @@ class CodegenContext {
110110 }
111111
112112 def declareMutableStates (): String = {
113+ // It's possible that we add same mutable state twice, e.g. the `mergeExpressions` in
114+ // `TypedAggregateExpression`, we should call `distinct` here to remove the duplicated ones.
113115 mutableStates.distinct.map { case (javaType, variableName, _) =>
114116 s " private $javaType $variableName; "
115117 }.mkString(" \n " )
116118 }
117119
118120 def initMutableStates (): String = {
121+ // It's possible that we add same mutable state twice, e.g. the `mergeExpressions` in
122+ // `TypedAggregateExpression`, we should call `distinct` here to remove the duplicated ones.
119123 mutableStates.distinct.map(_._3).mkString(" \n " )
120124 }
121125
You can’t perform that action at this time.
0 commit comments