lsyldliu commented on code in PR #22990:
URL: https://github.com/apache/flink/pull/22990#discussion_r1271258336
##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/agg/batch/AggCodeGenHelper.scala:
##########
@@ -45,11 +45,16 @@ import scala.annotation.tailrec
/** Batch aggregate code generate helper. */
object AggCodeGenHelper {
+ /**
+ * The aggBufferPrefix is used to guarantee the variable name unique in OFCG
case, so user should
+ * guarantee the aggBufferPrefix unique in this case.
+ */
def getAggBufferNames(
+ aggBufferPrefix: String,
Review Comment:
No, we can't. This `aggBufferPrefix ` is used to solve the case where agg
without key. The aggBuffer field name is hardcode to
[`agg${aggBufferIdx}_${attr.getName}`](https://github.com/apache/flink/blob/59850a91f96ddb5c58d8554b76e46bc6245dda7b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/agg/batch/AggCodeGenHelper.scala#L62)
in current implementation. Then we get the aggbuffer field in
[toAggBufferExpr](https://github.com/apache/flink/blob/59850a91f96ddb5c58d8554b76e46bc6245dda7b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/agg/batch/AggCodeGenHelper.scala#L275)
also base on this assembling rule. If we new `newName(...)` method, we can't
get it later. So here I guarantee its uniqueness by outer call place.
```
private lazy val aggBufferPrefix: String = if (isFinal) { newName("hash") }
else { newName("local_hash") }
private lazy val aggBufferNames =
AggCodeGenHelper.getAggBufferNames(aggBufferPrefix, auxGrouping, aggInfos
```
--
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]