dianfu commented on a change in pull request #7209: [FLINK-10977][table] Add UnBounded FlatAggregate operator to streaming Table API URL: https://github.com/apache/flink/pull/7209#discussion_r241290354
########## File path: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/TableAggregationCodeGenerator.scala ########## @@ -0,0 +1,287 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.flink.table.codegen + +import org.apache.calcite.rex.RexLiteral +import org.apache.flink.api.common.typeinfo.TypeInformation +import org.apache.flink.table.api.TableConfig +import org.apache.flink.table.api.dataview._ +import org.apache.flink.table.codegen.Indenter.toISC +import org.apache.flink.table.functions.UserDefinedAggregateFunction +import org.apache.flink.table.runtime.aggregate.GeneratedTableAggregations +import org.apache.flink.table.runtime.types.CRow +import org.apache.flink.table.utils.RetractableCollector +import org.apache.flink.types.Row +import org.apache.flink.util.Collector +import org.apache.flink.table.codegen.TableAggregationCodeGenerator._ +import org.apache.flink.table.plan.schema.RowSchema + +/** + * A base code generator for generating [[GeneratedTableAggregations]]. + * + * @param config configuration that determines runtime behavior + * @param nullableInput input(s) can be null. + * @param input type information about the input of the Function + * @param constants constant expressions that act like a second input in the + * parameter indices. + * @param name Class name of the function. + * Does not need to be unique but has to be a valid Java class + * identifier. + * @param physicalInputTypes Physical input row types + * @param tableAggOutputTypes Output types of TableAggregateFunction + * @param outputSchema The type of the rows emitted by TableAggregate operator + * @param aggregates All aggregate functions + * @param aggFields Indexes of the input fields for all aggregate functions + * @param aggMapping The mapping of aggregates to output fields + * @param isDistinctAggs The flag array indicating whether it is distinct aggregate. + * @param isStateBackedDataViews a flag to indicate if distinct filter uses state backend. + * @param partialResults A flag defining whether final or partial results (accumulators) + * are set + * to the output row. + * @param fwdMapping The mapping of input fields to output fields + * @param mergeMapping An optional mapping to specify the accumulators to merge. If not + * set, we + * assume that both rows have the accumulators at the same position. + * @param outputArity The number of fields in the output row. + * @param needRetract a flag to indicate if the aggregate needs the retract method + * @param needEmitWithRetract a flag to indicate if the aggregate needs to output retractions + * when update + * @param needMerge a flag to indicate if the aggregate needs the merge method + * @param needReset a flag to indicate if the aggregate needs the resetAccumulator + * method + * @param accConfig Data view specification for accumulators + */ +class TableAggregationCodeGenerator( + config: TableConfig, + nullableInput: Boolean, + input: TypeInformation[_ <: Any], + constants: Option[Seq[RexLiteral]], + name: String, + physicalInputTypes: Seq[TypeInformation[_]], + tableAggOutputTypes: TypeInformation[_], + outputSchema: RowSchema, Review comment: tableAggOutputTypes can be computed from outputSchema ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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