Skip to content

Commit cda9723

Browse files
committed
address comments
1 parent 45608b1 commit cda9723

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class EquivalentExpressions {
7878
// 1. CodegenFallback: it's children will not be used to generate code (call eval() instead)
7979
// 2. conditional expressions: common subexpressions will always be evaluated at the
8080
// beginning, so we should not recurse into condition expressions,
81-
// whole children may not get evaluated.
81+
// whole children may not get accessed according to the condition.
8282
val shouldRecurse = expr match {
8383
case _: CodegenFallback => false
8484
case _: If => false

sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/TypedAggregateExpression.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ case class SimpleTypedAggregateExpression(
143143
override lazy val aggBufferAttributes: Seq[AttributeReference] =
144144
bufferSerializer.map(_.toAttribute.asInstanceOf[AttributeReference])
145145

146-
private def deserializeToBuffer(expr: Expression): Seq[Expression] = {
147-
bufferDeserializer.map(_.transform {
146+
private def serializeToBuffer(expr: Expression): Seq[Expression] = {
147+
bufferSerializer.map(_.transform {
148148
case _: BoundReference => expr
149149
})
150150
}
151151

152152
override lazy val initialValues: Seq[Expression] = {
153153
val zero = Literal.fromObject(aggregator.zero, bufferExternalType)
154-
deserializeToBuffer(zero)
154+
serializeToBuffer(zero)
155155
}
156156

157157
override lazy val updateExpressions: Seq[Expression] = {
@@ -160,7 +160,7 @@ case class SimpleTypedAggregateExpression(
160160
"reduce",
161161
bufferExternalType,
162162
bufferDeserializer :: inputDeserializer.get :: Nil)
163-
deserializeToBuffer(reduced)
163+
serializeToBuffer(reduced)
164164
}
165165

166166
override lazy val mergeExpressions: Seq[Expression] = {
@@ -175,7 +175,7 @@ case class SimpleTypedAggregateExpression(
175175
"merge",
176176
bufferExternalType,
177177
leftBuffer :: rightBuffer :: Nil)
178-
deserializeToBuffer(merged)
178+
serializeToBuffer(merged)
179179
}
180180

181181
override lazy val evaluateExpression: Expression = {
@@ -185,17 +185,17 @@ case class SimpleTypedAggregateExpression(
185185
outputExternalType,
186186
bufferDeserializer :: Nil)
187187

188-
val serializeExprs = outputSerializer.map(_.transform {
188+
val outputSerializeExprs = outputSerializer.map(_.transform {
189189
case _: BoundReference => resultObj
190190
})
191191

192192
dataType match {
193193
case _: StructType =>
194194
val objRef = outputSerializer.head.find(_.isInstanceOf[BoundReference]).get
195-
If(IsNull(objRef), Literal.create(null, dataType), CreateStruct(serializeExprs))
195+
If(IsNull(objRef), Literal.create(null, dataType), CreateStruct(outputSerializeExprs))
196196
case _ =>
197-
assert(serializeExprs.length == 1)
198-
serializeExprs.head
197+
assert(outputSerializeExprs.length == 1)
198+
outputSerializeExprs.head
199199
}
200200
}
201201

0 commit comments

Comments
 (0)