lsyldliu commented on code in PR #21586:
URL: https://github.com/apache/flink/pull/21586#discussion_r1065306202


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/agg/batch/HashAggCodeGenerator.scala:
##########
@@ -202,11 +299,43 @@ class HashAggCodeGenerator(
          |    $dealWithAggHashMapOOM
          |  }
          |}
+         |
+         |$totalCountIncCode
+         |$adaptiveSamplePointCode
+         |
          | // aggregate buffer fields access
          |${ctx.reuseInputUnboxingCode(currentAggBufferTerm)}
          | // do aggregate and update agg buffer
          |${aggregate.code}
+         | // flush result form map if suppress is enable. 
+         |$flushResultIfSuppressEnableCode
          |""".stripMargin.trim
+    } else {
+      s"""

Review Comment:
   We don't need this repeated code, for local and global agg, the main code is 
reusable. For example, the `adaptiveSuppressCode ` for global agg is "", but 
for local agg is the needed code.



##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/GenerateUtils.scala:
##########
@@ -610,6 +610,58 @@ object GenerateUtils {
       generateInputFieldUnboxing(ctx, inputType, inputCode, inputCode)
   }
 
+  def generateFieldAccessForCountCol(

Review Comment:
   Add some annotation for these two methods?



##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/plan/nodes/physical/batch/BatchPhysicalHashAggregate.scala:
##########
@@ -53,7 +53,8 @@ class BatchPhysicalHashAggregate(
     grouping: Array[Int],
     auxGrouping: Array[Int],
     aggCallToAggFunction: Seq[(AggregateCall, UserDefinedFunction)],
-    isMerge: Boolean)
+    isMerge: Boolean,
+    canProjection: Boolean)

Review Comment:
   For global hash agg, we don't need this variable, it should always be false.



##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/GenerateUtils.scala:
##########
@@ -610,6 +610,58 @@ object GenerateUtils {
       generateInputFieldUnboxing(ctx, inputType, inputCode, inputCode)
   }
 
+  def generateFieldAccessForCountCol(
+      ctx: CodeGeneratorContext,
+      inputType: LogicalType,
+      inputTerm: String,
+      index: Int): GeneratedExpression = inputType.getTypeRoot match {
+    // ordered by type root definition
+    case ROW | STRUCTURED_TYPE =>

Review Comment:
   Do we support count `row` or `structured` type now?



-- 
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]

Reply via email to