zhztheplayer commented on code in PR #5575:
URL: https://github.com/apache/incubator-gluten/pull/5575#discussion_r1591727534
##########
gluten-core/src/main/scala/org/apache/gluten/execution/HashAggregateExecBaseTransformer.scala:
##########
@@ -172,12 +172,32 @@ abstract class HashAggregateExecBaseTransformer(
validation: Boolean = false): RelNode
}
-abstract class HashAggregateExecPullOutBaseHelper(
- groupingExpressions: Seq[NamedExpression],
- aggregateExpressions: Seq[AggregateExpression],
- aggregateAttributes: Seq[Attribute]) {
+object HashAggregateExecBaseTransformer {
+
+ private def getInitialInputBufferOffset(agg: BaseAggregateExec): Int = agg
match {
+ case a: HashAggregateExec => a.initialInputBufferOffset
+ case a: ObjectHashAggregateExec => a.initialInputBufferOffset
+ case a: SortAggregateExec => a.initialInputBufferOffset
+ }
+
+ def from(agg: BaseAggregateExec)(
+ childConverter: SparkPlan => SparkPlan = p => p):
HashAggregateExecBaseTransformer = {
+ BackendsApiManager.getSparkPlanExecApiInstance
+ .genHashAggregateExecTransformer(
+ agg.requiredChildDistributionExpressions,
+ agg.groupingExpressions,
+ agg.aggregateExpressions,
+ agg.aggregateAttributes,
+ getInitialInputBufferOffset(agg),
+ agg.resultExpressions,
+ childConverter(agg.child)
+ )
+ }
+}
+
+trait HashAggregateExecPullOutBaseHelper {
// The direct outputs of Aggregation.
- lazy val allAggregateResultAttributes: List[Attribute] =
+ def allAggregateResultAttributes(groupingExpressions: Seq[NamedExpression]):
List[Attribute] =
Review Comment:
I'll open to both because actually the change is not needed by this PR
anymore... But once I needed `getAttrForAggregateExprs` to be exposed for RAS's
agg validation but after sometime I reverted that approach since it messed up
code.
Back to this trait, I am feeling it's not that bad to only include required
arguments to get more flexibility. However again I no longer need this change
so feel free to change to another approach in future development if needed.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]