dianfu commented on a change in pull request #7177: [FLINK-7599] [table] 
Support for aggregates in MATCH_RECOGNIZE
URL: https://github.com/apache/flink/pull/7177#discussion_r237472659
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/MatchCodeGenerator.scala
 ##########
 @@ -442,4 +498,223 @@ class MatchCodeGenerator(
 
     generateFieldAccess(patternVariableRef.copy(code = NO_CODE), 
fieldRef.getIndex)
   }
+
+  class AggBuilder(variable: String) {
+
+    private val aggregates = new mutable.ListBuffer[RexCall]()
+
+    private val variableUID = newName("variable")
+
+    private val resultRowTerm = newName(s"aggRow_$variableUID")
+
+    private val rowTypeTerm = "org.apache.flink.types.Row"
+
+    def getOrAddAggregation(call: RexCall): GeneratedExpression = {
+      reusableInputUnboxingExprs.get((call.toString, 0)) match  {
+        case Some(expr) =>
+          expr
+
+        case None =>
+          val exp: GeneratedExpression = generateAggAccess(call)
+          aggregates += call
+          reusableInputUnboxingExprs((call.toString, 0)) = exp
+          exp.copy(code = NO_CODE)
+      }
+    }
+
+    private def generateAggAccess(call: RexCall) = {
 
 Review comment:
   What about renaming to generateAggregation?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to