hequn8128 commented on a change in pull request #7209: [FLINK-10977][table] Add UnBounded FlatAggregate operator to streaming Table API URL: https://github.com/apache/flink/pull/7209#discussion_r246238933
########## File path: docs/dev/table/tableApi.md ########## @@ -550,6 +550,82 @@ val result = orders.distinct() {% top %} +### TableAggregations + +<div class="codetabs" markdown="1"> +<div data-lang="java" markdown="1"> + +<table class="table table-bordered"> + <thead> + <tr> + <th class="text-left" style="width: 20%">Operators</th> + <th class="text-center">Description</th> + </tr> + </thead> + <tbody> + <tr> + <td> + <strong>GroupBy TableAggregation</strong><br> + <span class="label label-primary">Streaming</span><br> + <span class="label label-info">Result Updating</span> + </td> + <td> + <p>Similar to a <b>GroupBy Aggregation</b>. Groups the rows on the grouping keys with a following running table aggregation operator to aggregate rows group-wise. The difference from an AggregateFunction is that TableAggregateFunction may return 0 or more records for a group. You have to close the "flatAggregate" with a select statement. And the select statement does not support aggregate functions.</p> +{% highlight java %} +TableAggregateFunction tableAggFunc = new MyTableAggregateFunction(); +tableEnv.registerFunction("myTableAggFunc", tableAggFunc); +Table orders = tableEnv.scan("Orders"); +Table result = orders + .groupBy("a") + .flatAggregate("myTableAggFunc(a, b, c)") + .select("_1 as a, _2 as b"); +{% endhighlight %} + <p><b>Note:</b> For streaming queries the required state to compute the query result might grow infinitely depending on the type of aggregation and the number of distinct grouping keys. Please provide a query configuration with valid retention interval to prevent excessive state size. See <a href="streaming/query_configuration.html">Query Configuration</a> for details.</p> + </td> + </tr> + + </tbody> +</table> + +</div> +<div data-lang="scala" markdown="1"> + +<table class="table table-bordered"> + <thead> + <tr> + <th class="text-left" style="width: 20%">Operators</th> + <th class="text-center">Description</th> + </tr> + </thead> + <tbody> + + <tr> + <td> + <strong>GroupBy TableAggregation</strong><br> + <span class="label label-primary">Streaming</span><br> + <span class="label label-info">Result Updating</span> + </td> + <td> + <p>Similar to a <b>GroupBy Aggregation</b>. Groups the rows on the grouping keys with a following running table aggregation operator to aggregate rows group-wise. The difference from an AggregateFunction is that TableAggregateFunction may return 0 or more records for a group. You have to close the "flatAggregate" with a select statement. And the select statement does not support aggregate functions.</p> +{% highlight scala %} +val tableAggFunc: TableAggregateFunction = new MyTableAggregateFunction Review comment: Oh, my fault. I think it should be `val tableAggFunc: TableAggregateFunction[_, _] = new MyTableAggregateFunction` ---------------------------------------------------------------- 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