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

    https://github.com/apache/flink/pull/3809#discussion_r114541011
  
    --- Diff: 
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/aggregations.scala
 ---
    @@ -130,3 +142,63 @@ case class Avg(child: Expression) extends Aggregation {
         new SqlAvgAggFunction(AVG)
       }
     }
    +
    +case class UDAGGFunctionCall(
    +    aggregateFunction: AggregateFunction[_, _],
    +    args: Seq[Expression])
    +  extends Aggregation {
    +
    +  override private[flink] def children: Seq[Expression] = args
    +
    +  // Override makeCopy method in TreeNode, to produce vargars properly
    +  override def makeCopy(args: Array[AnyRef]): this.type = {
    +    if (args.length < 1) {
    +      throw new TableException("Invalid constructor params")
    +    }
    +    val agg = args.head.asInstanceOf[AggregateFunction[_, _]]
    +    val arg = args.last.asInstanceOf[Seq[Expression]]
    +    new UDAGGFunctionCall(agg, arg).asInstanceOf[this.type]
    +  }
    +
    +  override def resultType: TypeInformation[_] = 
TypeExtractor.createTypeInfo(
    --- End diff --
    
    This is again very dangerous. Type extraction fails very often. We should 
provide a `getResultType` in `AggregateFunction` that the user can implement.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to