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_r244676277
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/table.scala
 ##########
 @@ -1226,3 +1301,81 @@ class WindowGroupedTable(
     select(withResolvedAggFunctionCall: _*)
   }
 }
+
+class AggregatedTable(
+    private[flink] val table: Table,
+    private[flink] val groupKeys: Seq[Expression],
+    private[flink] val aggregateFunction: Expression) {
+
+  /**
+    * Performs a selection operation after an aggregate operation. The field 
expressions
+    * cannot contain table functions and aggregations.
+    *
+    * 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 select(fields: Expression*): Table = {
+    val tableEnv = table.tableEnv
+    val (aggNames, propNames) = 
extractAggregationsAndProperties(Seq(aggregateFunction), tableEnv)
+    val projectsOnAgg = replaceAggregationsAndProperties(
 
 Review comment:
   Can we check the select aggregate by the follows code if we do not need 
check tvf?
   
   ```
   val (aggNames, propNames) =
         extractAggregationsAndProperties(Seq(aggregateFunction) ++ fields, 
tableEnv)
   
       if(aggNames.size > 1) {
         throw new ValidationException(
           "Can not do the aggregation in the aggregated Table's select.")
       }
   ```
   What do you think?

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

Reply via email to