sunjincheng121 commented on a change in pull request #7235: [FLINK-10976]
[table] Add support for aggregate to table API
URL: https://github.com/apache/flink/pull/7235#discussion_r244670679
##########
File path:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/table.scala
##########
@@ -1080,6 +1114,47 @@ class GroupedTable(
val withResolvedAggFunctionCall = fieldExprs.map(replaceAggFunctionCall(_,
table.tableEnv))
select(withResolvedAggFunctionCall: _*)
}
+
+ /**
+ * Performs an aggregate operation with an aggregate function. Use this
before a selection
+ * to perform the selection operation. The output will be flattened if the
output type is a
+ * composite type.
+ *
+ * Example:
+ *
+ * {{{
+ * val aggFunc: AggregateFunction[_, _] = new MyAggregateFunction
+ * tableEnv.registerFunction("aggFunc", aggFunc);
+ * table.groupBy('key).aggregate("aggFunc(a, b) as (f0, f1,
f2)").select('key, 'f0, 'f1)
+ * }}}
+ */
+ def aggregate(aggregateFunction: Expression): AggregatedTable = {
+ unwrap(aggregateFunction, table.tableEnv) match {
+ case _: AggFunctionCall | _: Aggregation =>
+ case _ => throw new ValidationException("Only AggregateFunction can be
used in aggregate.")
+ }
+
+ new AggregatedTable(table, groupKeys, aggregateFunction)
+ }
+
+ /**
+ * Performs an aggregate operation with an aggregate function. Use this
before a selection
+ * to perform the selection operation. The output will be flattened if the
output type is a
+ * composite type.
+ *
+ * Example:
+ *
+ * {{{
+ * val aggFunc: AggregateFunction[_, _] = new MyAggregateFunction
Review comment:
Can not using AggregateFunction[_, _].
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services