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

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_r211270531
 
 

 ##########
 File path: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/functions/AggregateFunction.scala
 ##########
 @@ -136,4 +138,12 @@ abstract class AggregateFunction[T, ACC] extends 
UserDefinedFunction {
     *         accumulator type should be automatically inferred.
     */
   def getAccumulatorType: TypeInformation[ACC] = null
+
+  /**
+    * Returns an aggregation function that requires distinct accumulator.
+    * @return distinct aggregate version of the [[AggregateFunction]].
+    */
+  private[flink] def distinct: DistinctAggregateFunction[T, ACC] = 
DistinctAggregateFunction(this)
 }
+
+private[flink] case class DistinctAggregateFunction[T, ACC](aggFunction: 
AggregateFunction[T, ACC])
 
 Review comment:
   Extend this class to
   
   ```
   private[flink] case class DistinctAggregateFunction[T: TypeInformation, ACC: 
TypeInformation]
       (aggFunction: AggregateFunction[T, ACC]) {
   
     private[flink] def distinct(params: Expression*): Expression = {
       val resultTypeInfo: TypeInformation[_] = 
getResultTypeOfAggregateFunction(
         aggFunction,
         implicitly[TypeInformation[T]])
   
       val accTypeInfo: TypeInformation[_] = 
getAccumulatorTypeOfAggregateFunction(
         aggFunction,
         implicitly[TypeInformation[ACC]])
   
       DistinctAgg(
         AggFunctionCall(aggFunction, resultTypeInfo, accTypeInfo, params))
     }
   }
   ```
   
   and move it to a separate file.

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