Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/4105#discussion_r122448432 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/TableEnvironment.scala --- @@ -358,20 +358,27 @@ abstract class TableEnvironment(val config: TableConfig) { * Registers an [[AggregateFunction]] under a unique name. Replaces already existing * user-defined functions under this name. */ - private[flink] def registerAggregateFunctionInternal[T: TypeInformation, ACC]( + private[flink] def registerAggregateFunctionInternal[T: TypeInformation, ACC: TypeInformation]( name: String, function: AggregateFunction[T, ACC]): Unit = { // check if class not Scala object checkNotSingleton(function.getClass) // check if class could be instantiated checkForInstantiation(function.getClass) - val typeInfo: TypeInformation[_] = implicitly[TypeInformation[T]] + val resultTypeInfo: TypeInformation[_] = implicitly[TypeInformation[T]] + val accTypeInfo: TypeInformation[_] = implicitly[TypeInformation[ACC]] // register in Table API functionCatalog.registerFunction(name, function.getClass) // register in SQL API - val sqlFunctions = createAggregateSqlFunction(name, function, typeInfo, typeFactory) + val sqlFunctions = createAggregateSqlFunction( --- End diff -- To be honest, I don't think it is a nice approach to add the acc type to the internal representation of UDAGGs. It is not related to the logic of the function or required for the optimization but rather an internal runtime aspect. An alternative could be to wrap the functions registered from Scala in a class that extends the `AggregateFunction` interface and holds the original agg function and the acc type information (exposed via the getAccumulatorType()` method). We would need to unwrap it before we translate it. It's not a super nice solution either, but would probably require fewer changes. What do you think?
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---