Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5706#discussion_r175716765
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/plan/nodes/logical/FlinkLogicalWindowAggregate.scala
 ---
    @@ -103,6 +106,22 @@ class FlinkLogicalWindowAggregateConverter
         FlinkConventions.LOGICAL,
         "FlinkLogicalWindowAggregateConverter") {
     
    +  override def matches(call: RelOptRuleCall): Boolean = {
    +    val agg = call.rel(0).asInstanceOf[LogicalWindowAggregate]
    +
    +    // we do not support these functions natively
    +    // they have to be converted using the 
WindowAggregateReduceFunctionsRule
    +    val supported = 
agg.getAggCallList.asScala.map(_.getAggregation.getKind).forall {
    +      // we support AVG
    +      case SqlKind.AVG => true
    +      // but none of the other AVG agg functions
    +      case k if SqlKind.AVG_AGG_FUNCTIONS.contains(k) => false
    +      case _ => true
    +    }
    +
    +    !agg.containsDistinctCall() && supported
    --- End diff --
    
    Hmm, that's a good point. 
    In fact, there won't be any plan with a `DISTINCT` aggregation in a 
`LogicalWindowAggregate` because `LogicalWindowAggregateRule` prevents 
translation of (`Calc(TUMBLE) -> Aggregate()`) into (`WindowAggregate(TUMBLE)`) 
if there is a distinct aggregate. This prevents window aggregates in SQL 
queries being translated into `WindowAggregate`. The Table API does not even 
have an API to define such queries.
    
    So, I'd simply remove the `containsDistinctCall()` check for now. We should 
definitely clean this up when we add support for DISTINCT aggregates.
    
    @walterddr, are you fine with this?



---

Reply via email to