maropu commented on a change in pull request #27019: [SPARK-30027][SQL] Support
codegen for aggregate filters in HashAggregateExec
URL: https://github.com/apache/spark/pull/27019#discussion_r371231181
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/aggregate/HashAggregateExec.scala
##########
@@ -329,6 +328,39 @@ case class HashAggregateExec(
}
}
+ private def generateEvalCodeForAggFuncs(
+ ctx: CodegenContext,
+ input: Seq[ExprCode],
+ inputAttrs: Seq[Attribute],
+ boundUpdateExprs: Seq[Seq[Expression]],
+ aggNames: Seq[String],
+ aggCodeBlocks: Seq[Block],
+ subExprs: SubExprCodes): String = {
+ val aggCodes = if (conf.codegenSplitAggregateFunc &&
+ aggCodeBlocks.map(_.length).sum > conf.methodSplitThreshold) {
+ val maybeSplitCodes = splitAggregateExpressions(
+ ctx, aggNames, boundUpdateExprs, aggCodeBlocks, subExprs.states)
+
+ maybeSplitCodes.getOrElse(aggCodeBlocks.map(_.code))
+ } else {
+ aggCodeBlocks.map(_.code)
+ }
+
+ aggCodes.zip(aggregateExpressions.map(ae => (ae.mode, ae.filter))).map {
+ case (aggCode, (Partial | Complete, Some(condition))) =>
+ // Note: wrap in "do { } while(false);", so the generated checks can
jump out
+ // with "continue;"
+ s"""
+ |do {
+ | ${generatePredicateCode(ctx, condition, inputAttrs, input)}
+ | $aggCode
+ |} while(false);
Review comment:
Thanks for the reply, @HeartSaVioR. Since I forgot to add the generated
code, I've added it in the PR description.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]