sunjincheng121 commented on a change in pull request #9396: [FLINK-13473][table-blink] Add stream Windowed FlatAggregate support for blink planner URL: https://github.com/apache/flink/pull/9396#discussion_r312684864
########## File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/operators/window/WindowOperatorBuilder.java ########## @@ -181,24 +194,79 @@ public WindowOperatorBuilder aggregate( LogicalType[] accumulatorTypes, LogicalType[] aggResultTypes, LogicalType[] windowPropertyTypes) { - this.accumulatorTypes = accumulatorTypes; - this.aggResultTypes = aggResultTypes; - this.windowPropertyTypes = windowPropertyTypes; + aggregate(accumulatorTypes, aggResultTypes, windowPropertyTypes); this.generatedAggregateFunction = checkNotNull(generatedAggregateFunction); this.generatedEqualiser = checkNotNull(generatedEqualiser); return this; } + public WindowOperatorBuilder aggregate( + NamespaceTableAggsHandleFunction<?> tableAggregateFunction, + LogicalType[] accumulatorTypes, + LogicalType[] aggResultTypes, + LogicalType[] windowPropertyTypes) { + ClosureCleaner.clean(tableAggregateFunction, ExecutionConfig.ClosureCleanerLevel.RECURSIVE, true); + aggregate(accumulatorTypes, aggResultTypes, windowPropertyTypes); + this.tableAggregateFunction = checkNotNull(tableAggregateFunction); + return this; + } + + public WindowOperatorBuilder aggregate( + GeneratedNamespaceTableAggsHandleFunction<?> generatedTableAggregateFunction, + LogicalType[] accumulatorTypes, + LogicalType[] aggResultTypes, + LogicalType[] windowPropertyTypes) { + aggregate(accumulatorTypes, aggResultTypes, windowPropertyTypes); + this.generatedTableAggregateFunction = checkNotNull(generatedTableAggregateFunction); + return this; + } + + @VisibleForTesting + public WindowOperatorBuilder aggregate( + NamespaceAggsHandleFunctionBase<?> aggregateFunction, + RecordEqualiser equaliser, + LogicalType[] accumulatorTypes, + LogicalType[] aggResultTypes, + LogicalType[] windowPropertyTypes) { + if (aggregateFunction instanceof NamespaceAggsHandleFunction) { + aggregate((NamespaceAggsHandleFunction) aggregateFunction, + equaliser, + accumulatorTypes, + aggResultTypes, + windowPropertyTypes); + } else { + aggregate((NamespaceTableAggsHandleFunction) aggregateFunction, + accumulatorTypes, + aggResultTypes, + windowPropertyTypes); + } + return this; + } + public WindowOperatorBuilder withSendRetraction() { this.sendRetraction = true; return this; } public WindowOperator build() { checkNotNull(trigger, "trigger is not set"); - if (generatedAggregateFunction != null && generatedEqualiser != null) { + if (generatedTableAggregateFunction != null) { Review comment: Good idea. We can make the WindowOperatorBuilder as a base builer and add two more builders for aggregate and table aggregate. What do you think? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services