kumarpritam863 commented on code in PR #18739: URL: https://github.com/apache/iceberg/pull/18739#discussion_r4520119931
########## flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/sink/dynamic/DynamicRecordExceptionFilter.java: ########## @@ -0,0 +1,48 @@ +/* + * 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.iceberg.flink.sink.dynamic; + +import java.io.Serializable; +import org.apache.flink.annotation.Experimental; + +/** + * Classifies a failure raised while processing a {@link DynamicRecord} as divertable or not. Keeps + * error handling fail-safe: only failures this filter whitelists are diverted to the error stream + * set via {@link DynamicIcebergSink.Builder#errorStreamConsumer}; every other failure propagates + * and fails the job so Flink's restart strategy can retry it. + * + * <p>Whitelist only deterministic, record-scoped failures (bad data, for example a value that + * cannot be encoded for its table, or an upsert record whose partition source is not an equality + * field). Return {@code false} for transient or systemic failures (an unreachable catalog, + * object-store errors, an interrupt) so a sustained outage does not silently drain the whole + * stream. + */ +@Experimental +@FunctionalInterface +public interface DynamicRecordExceptionFilter extends Serializable { + + /** + * Classifies a failure as divertable or not. + * + * @param error the cause thrown while processing a record + * @return {@code true} to divert the record, {@code false} to propagate the failure and fail the + * job + */ + boolean shouldDivert(Exception error); Review Comment: I added a dedicated DynamicRecordException (@Experimental). It is thrown for failures caused by the record: nulls in required columns, an invalid upsert configuration, an equality or distribution field that is not in the schema, a required column that the input schema lacks, and schema changes the table cannot take. Those are wrapped where the schema update is built, and commit conflicts are not wrapped because they can be transient. A filter is then error -> error instanceof DynamicRecordException, which the Javadoc shows. Before, these surfaced as IllegalArgumentException, IllegalStateException and NullPointerException, which cannot be told apart from systemic failures. But i think this is becoming like a flag which I put initially. May be I am thinking is we can have the "DynamicRecordException" and then a flag based control that whether to divert these exception to side stream. 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
