Skip to content

Commit a57f8e6

Browse files
committed
add comments
1 parent 3426310 commit a57f8e6

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/EquivalentExpressions.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/codegen/CodeGenerator.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)