[ 
https://issues.apache.org/jira/browse/FLINK-5315?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16585960#comment-16585960
 ] 

ASF GitHub Bot commented on FLINK-5315:
---------------------------------------

fhueske commented on a change in pull request #6521: [FLINK-5315][table] Adding 
support for distinct operation for table API on DataStream
URL: https://github.com/apache/flink/pull/6521#discussion_r211208758
 
 

 ##########
 File path: docs/dev/table/tableApi.md
 ##########
 @@ -381,6 +381,36 @@ Table result = orders
 {% highlight java %}
 Table orders = tableEnv.scan("Orders");
 Table result = orders.distinct();
+{% endhighlight %}
+        <p><b>Note:</b> For streaming queries the required state to compute 
the query result might grow infinitely depending on the number of distinct 
fields. Please provide a query configuration with valid retention interval to 
prevent excessive state size. See <a href="streaming.html">Streaming 
Concepts</a> for details.</p>
+      </td>
+    </tr>
+    <tr>
+      <td>
+        <strong>Distinct Aggregation</strong><br>
+        <span class="label label-primary">Streaming</span>
+      </td>
+      <td>
+        <p>Similar to a SQL DISTINCT AGGREGATION clause such as COUNT(DISTINCT 
a). Returns aggregation results with a following running aggregation operator 
to aggregate over rows with only distinct value. Distinct aggregations can 
operator with <b>GroupBy Aggregation</b>, <b>GroupBy Window Aggregation</b> and 
<b>Over Window Aggregation</b>.</p>
+{% highlight java %}
+Table orders = tableEnv.scan("Orders");
+// Distinct aggregation on group by
+Table groupByDistinctResult = orders
+    .groupBy("a")
+    .select("a, b.sum.distinct as d");
+// Distinct aggregation on time window group by
+Table groupByWindowDistinctResult = orders
+    .window(Tumble.over("5.minutes").on("rowtime").as("w")).groupBy("a, w")
+    .select("a, b.sum.distinct as d");
+// Distinct aggregation on over window
+Table result = orders
+    .window(Over
+        .partitionBy("a")
+        .orderBy("rowtime")
+        .preceding("UNBOUNDED_RANGE")
+        .following("CURRENT_RANGE")
 
 Review comment:
   `following` can be omitted (defaults to `CURRENT_RANGE`)

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


> Support distinct aggregations in table api
> ------------------------------------------
>
>                 Key: FLINK-5315
>                 URL: https://issues.apache.org/jira/browse/FLINK-5315
>             Project: Flink
>          Issue Type: Sub-task
>          Components: Table API &amp; SQL
>            Reporter: Kurt Young
>            Assignee: Rong Rong
>            Priority: Major
>              Labels: pull-request-available
>
> Support distinct aggregations in Table API in the following format:
> For Expressions:
> {code:scala}
> 'a.count.distinct // Expressions distinct modifier
> {code}
> For User-defined Function:
> {code:scala}
> singleArgUdaggFunc.distinct('a) // FunctionCall distinct modifier
> multiArgUdaggFunc.distinct('a, 'b) // FunctionCall distinct modifier
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to