Github user fhueske commented on a diff in the pull request: https://github.com/apache/flink/pull/3641#discussion_r108722685 --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/runtime/aggregate/AggregateUtil.scala --- @@ -1208,5 +1208,40 @@ object AggregateUtil { private def gcd(a: Long, b: Long): Long = { if (b == 0) a else gcd(b, a % b) } -} + + /** + * Create an [[org.apache.flink.streaming.api.functions.ProcessFunction]] to evaluate final + * aggregate value over a window with processing time boundaries. + * + * @param namedAggregates List of calls to aggregate functions and their output field names + * @param inputType Input row type + * @param timeBoundary time limit of the window boundary expressed in milliseconds + * @param isPartitioned Flag to indicate whether the input is partitioned or not + * @return [[org.apache.flink.streaming.api.functions.ProcessFunction]] + */ + private[flink] def createTimeBoundedProcessingOverProcessFunction( + namedAggregates: Seq[CalcitePair[AggregateCall, String]], + inputType: RelDataType, + timeBoundary: Long, + isPartitioned: Boolean = true): ProcessFunction[Row, Row] = { + + val (aggFields, aggregates) = + transformToAggregateFunctions( + namedAggregates.map(_.getKey), + inputType, + needRetraction = false) --- End diff -- `needRetraction` must be `true`. This is probably not caught by the tests, because the agg functions in the test are always retractable. You could use a `min` or `max` aggregation which have dedicated implementation for retraction. Actually, we should check if the over window tests have `min` and `max` agg functions as well. I'll do that once all over windows have been merged.
--- 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. ---