Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/3809#discussion_r114448779
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
---
@@ -274,27 +278,73 @@ class CodeGenerator(
constantFlags: Option[Array[(Int, Boolean)]],
outputArity: Int,
needRetract: Boolean,
- needMerge: Boolean)
+ needMerge: Boolean,
+ needReset: Boolean)
: GeneratedAggregationsFunction = {
// get unique function name
val funcName = newName(name)
// register UDAGGs
val aggs = aggregates.map(a => generator.addReusableFunction(a))
// get java types of accumulators
- val accTypes = aggregates.map { a =>
-
a.getClass.getMethod("createAccumulator").getReturnType.getCanonicalName
+ val accTypeClasses = aggregates.map { a =>
+ val accType = TypeExtractor.createTypeInfo(a,
classOf[AggregateFunction[_, _]], a.getClass, 1)
+ accType.getTypeClass
}
+ val accTypes = accTypeClasses.map(_.getCanonicalName)
- // get java types of input fields
- val javaTypes = inputType.getFieldList
+ // get java classes of input fields
+ val javaClasses = inputType.getFieldList
.map(f => FlinkTypeFactory.toTypeInfo(f.getType))
- .map(t => t.getTypeClass.getCanonicalName)
+ .map(t => t.getTypeClass)
// get parameter lists for aggregation functions
- val parameters = aggFields.map {inFields =>
- val fields = for (f <- inFields) yield s"(${javaTypes(f)})
input.getField($f)"
+ val parameters = aggFields.map { inFields =>
+ val fields = for (f <- inFields) yield
+ s"(${javaClasses(f).getCanonicalName}) input.getField($f)"
fields.mkString(", ")
}
+ val methodSignaturesList = aggFields.map {
+ inFields => for (f <- inFields) yield javaClasses(f)
+ }
+
+ // check and validate the needed methods
+ aggregates.zipWithIndex.map {
+ case (a, i) => {
+ getUserDefinedMethod(a, "accumulate", Array(accTypeClasses(i)) ++
methodSignaturesList(i))
+ .getOrElse(
+ throw new CodeGenException(
+ s"No matching accumulate method found for aggregate " +
--- End diff --
add parameter classes to exception, e.g., `... for aggregation function
<class name> and parameters <parameter classes>`
---
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.
---