Github user yhuai commented on a diff in the pull request:
https://github.com/apache/spark/pull/9038#discussion_r41667789
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/TungstenAggregationIterator.scala
---
@@ -288,17 +419,33 @@ class TungstenAggregationIterator(
val joinedRow = new JoinedRow()
val evalExpressions = allAggregateFunctions.map {
case ae: DeclarativeAggregate => ae.evaluateExpression
- // case agg: AggregateFunction2 => Literal.create(null,
agg.dataType)
+ case agg: AggregateFunction2 => NoOp
}
- val expressionAggEvalProjection =
UnsafeProjection.create(evalExpressions, bufferAttributes)
+ val expressionAggEvalProjection =
newMutableProjection(evalExpressions, bufferAttributes)()
// These are the attributes of the row produced by
`expressionAggEvalProjection`
val aggregateResultSchema = nonCompleteAggregateAttributes ++
completeAggregateAttributes
+ // TODO: Use unsafe row.
+ val aggregateResult = new
SpecificMutableRow(aggregateResultSchema.map(_.dataType))
+ expressionAggEvalProjection.target(aggregateResult)
val resultProjection =
UnsafeProjection.create(resultExpressions, groupingAttributes ++
aggregateResultSchema)
+ val allImperativeAggregateFunctions: Array[ImperativeAggregate] =
+ allImperativeAggregateFunctionPositions
+ .map(allAggregateFunctions)
+ .map(_.asInstanceOf[ImperativeAggregate])
+
(currentGroupingKey: UnsafeRow, currentBuffer: UnsafeRow) => {
// Generate results for all expression-based aggregate functions.
- val aggregateResult =
expressionAggEvalProjection.apply(currentBuffer)
+ expressionAggEvalProjection(currentBuffer)
+ // Generate results for all imperative aggregate functions.
+ var i = 0
+ while (i < allImperativeAggregateFunctions.length) {
+ aggregateResult.update(
--- End diff --
This `update` prevent us from using `UnsafeRow`, right?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]