gustavodemorais commented on code in PR #29967: URL: https://github.com/apache/flink/pull/29967#discussion_r4628297073
########## flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/ptf/DeduplicateUtils.java: ########## @@ -0,0 +1,175 @@ +/* + * 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.runtime.functions.ptf; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.api.dataview.ValueView; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.functions.FunctionContext; +import org.apache.flink.table.functions.SpecializedFunction.ExpressionEvaluator; +import org.apache.flink.table.functions.SpecializedFunction.SpecializedContext; +import org.apache.flink.table.functions.TableSemantics; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.inference.StateTypeStrategy; +import org.apache.flink.table.types.inference.strategies.DeduplicateTypeStrategyUtils.Keep; +import org.apache.flink.table.types.utils.DataTypeUtils; +import org.apache.flink.util.FlinkRuntimeException; + +import javax.annotation.Nullable; + +import java.io.Serializable; +import java.lang.invoke.MethodHandle; +import java.time.Duration; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; + +import static org.apache.flink.table.api.Expressions.$; +import static org.apache.flink.table.api.Expressions.ifThenElse; +import static org.apache.flink.table.types.inference.strategies.DeduplicateTypeStrategy.ARG_INPUT; +import static org.apache.flink.table.types.inference.strategies.DeduplicateTypeStrategy.ARG_STATE_TTL; + +/** Record ordering of the built-in deduplication PTFs. */ +@Internal +public final class DeduplicateUtils { + + public static TableSemantics tableSemantics(final SpecializedContext context) { + return context.getCallContext() + .getTableSemantics(ARG_INPUT) + .orElseThrow(() -> new IllegalStateException("Table argument expected.")); + } + + /** Returns the fields of the input row without time attributes. */ + public static List<DataTypes.Field> inputFields(final SpecializedContext context) { Review Comment: This and `DeduplicateTypeStrategyUtils.outputFields` both strip time attributes field by field. `LogicalTypeUtils.removeTimeAttributes` already does that for a whole `ROW` type, since it's a `LogicalTypeDuplicator` that recurses into the fields, so a single call on the row type should replace both loops. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
