matriv commented on a change in pull request #17811: URL: https://github.com/apache/flink/pull/17811#discussion_r751691359
########## File path: flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/sink/ConstraintValidator.java ########## @@ -0,0 +1,201 @@ +/* + * 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.operators.sink; + +import org.apache.flink.annotation.Internal; +import org.apache.flink.api.java.tuple.Tuple2; +import org.apache.flink.streaming.api.operators.OneInputStreamOperator; +import org.apache.flink.streaming.runtime.streamrecord.StreamRecord; +import org.apache.flink.table.api.TableException; +import org.apache.flink.table.api.config.ExecutionConfigOptions.NotNullEnforcer; +import org.apache.flink.table.data.RowData; +import org.apache.flink.table.data.StringData; +import org.apache.flink.table.data.UpdatableRowData; +import org.apache.flink.table.runtime.operators.TableStreamOperator; + +import java.util.ArrayList; +import java.util.List; + +import static org.apache.flink.table.api.config.ExecutionConfigOptions.CharPrecisionEnforcer; +import static org.apache.flink.table.api.config.ExecutionConfigOptions.TABLE_EXEC_SINK_CHAR_PRECISION_ENFORCER; +import static org.apache.flink.table.api.config.ExecutionConfigOptions.TABLE_EXEC_SINK_NOT_NULL_ENFORCER; +import static org.apache.flink.util.Preconditions.checkArgument; + +/** Checks writing null values into NOT NULL columns. */ +@Internal +public class ConstraintValidator extends TableStreamOperator<RowData> + implements OneInputStreamOperator<RowData, RowData> { + + private static final long serialVersionUID = 1L; + + private final NotNullEnforcer notNullEnforcer; + private final int[] notNullFieldIndices; + private final String[] allFieldNames; + private final CharPrecisionEnforcer charPrecisionEnforcer; + private final List<Tuple2<Integer, Integer>> charFields; Review comment: I used a List of `Tuple2` because in the `CommonExecSink` I want to extract them with one loop, so couldn't return 2 arrays. Instead I could return directly a `long[]` where the 2 ints (fieldIdx and precision) are packed into 1 long, but it gets a bit "complicated", Check https://github.com/apache/flink/pull/17811/commits/2b885bb3d72eb7489b8aa3211d63a7c1b7ca591d and please share your opinion. -- 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: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org