-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dead letter table #233
Open
tabmatfournier
wants to merge
36
commits into
main
Choose a base branch
from
dead-letter-table
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Dead letter table #233
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
03c3e36
dead-letter-table
tabmatfournier e87d820
next steps
tabmatfournier b062c51
moved transform in
tabmatfournier 9b7f6b0
more refactoring
tabmatfournier c1b4de2
even more refactoring
tabmatfournier 4e706e1
cruft
tabmatfournier f9136d8
even more cruft
tabmatfournier d3905a5
tests
tabmatfournier 18c79ba
table create exceptions
tabmatfournier 77aad4b
introduces identifier column, more error handle wrapping
tabmatfournier edc75a5
make converter/smt error converters configurable/user extensible
tabmatfournier 8ee6840
introduce catalogApi to make IcebergWriterFactory testing easier
tabmatfournier de479d3
catalogApi and test stubs
tabmatfournier b78a68d
finished tests
tabmatfournier ac5d6a5
negate
tabmatfournier 50b300b
dead-letter-table
tabmatfournier 01f8cbb
put null record dropping back into iceberg writer
tabmatfournier d89f15a
fix dead letter utils private constructor
tabmatfournier c5c2186
fix cruft in readme
tabmatfournier 831f205
Merge branch 'main' into dead-letter-table
tabmatfournier 451e20f
Merge branch 'main' into dead-letter-table
tabmatfournier 41c4372
post-merge fixes
tabmatfournier 13220e9
more comments removing cruft
tabmatfournier 797b861
regexrecordrouter
tabmatfournier 7bd7d5d
start of fallback mode
tabmatfournier bff7233
third mode
tabmatfournier 25208da
another test case
tabmatfournier 205c2d7
better regex detection to avoid an extra config
tabmatfournier 4aeedcd
cruft cleanup and starting docs
tabmatfournier 0cf18d1
fix error transform tests
tabmatfournier 05ea87f
more docs
tabmatfournier 457a2f3
Merge branch 'main' into dead-letter-table
tabmatfournier 1518cc7
Merge branch 'main' into dead-letter-table
tabmatfournier e4977c4
dead-letter-table
tabmatfournier 4036557
rename module to not include deadletter
tabmatfournier 0ff7972
moved writeExceptions into exception module
tabmatfournier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
plugins { | ||
id "java-test-fixtures" | ||
} | ||
|
||
dependencies { | ||
implementation libs.iceberg.core | ||
compileOnly libs.bundles.kafka.connect | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
from components.java | ||
} | ||
} | ||
} |
89 changes: 89 additions & 0 deletions
89
.../main/java/io/tabular/iceberg/connect/exception/DeadLetterTableWriteExceptionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
* 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 io.tabular.iceberg.connect.exception; | ||
|
||
import org.apache.iceberg.exceptions.ValidationException; | ||
import org.apache.kafka.connect.sink.SinkRecord; | ||
import org.apache.kafka.connect.sink.SinkTaskContext; | ||
|
||
import java.util.Map; | ||
|
||
public class DeadLetterTableWriteExceptionHandler implements WriteExceptionHandler { | ||
private FailedRecordFactory factory; | ||
|
||
@Override | ||
public void initialize( | ||
SinkTaskContext context, Map<String, String> props) { | ||
String failedRecordFactoryClass = props.get("failed_record_factory"); | ||
factory = (FailedRecordFactory) DeadLetterUtils.loadClass(failedRecordFactoryClass, this.getClass().getClassLoader()); | ||
factory.configure(props); | ||
} | ||
|
||
@Override | ||
public SinkRecord handle(SinkRecord record, Exception exception) { | ||
if (exception instanceof WriteException) { | ||
return handleWriteException(record, (WriteException) exception); | ||
} | ||
Throwable cause = exception.getCause(); | ||
if (cause instanceof WriteException) { | ||
return handleWriteException(record, (WriteException) cause); | ||
} | ||
throw new RuntimeException(exception); | ||
} | ||
|
||
@SuppressWarnings("checkstyle:CyclomaticComplexity") | ||
private SinkRecord handleWriteException(SinkRecord record, WriteException exception) { | ||
if (exception instanceof WriteException.CreateTableException) { | ||
Throwable cause = exception.getCause(); | ||
if (cause instanceof IllegalArgumentException || cause instanceof ValidationException) { | ||
return failedRecord(record, exception); | ||
} | ||
} else if (exception instanceof WriteException.CreateSchemaException) { | ||
return failedRecord(record, exception); | ||
} else if (exception instanceof WriteException.LoadTableException) { | ||
Throwable cause = exception.getCause(); | ||
if (cause instanceof IllegalArgumentException || cause instanceof ValidationException) { | ||
return failedRecord(record, exception); | ||
} | ||
} else if (exception instanceof WriteException.RecordConversionException) { | ||
return failedRecord(record, exception); | ||
|
||
} else if (exception instanceof WriteException.RouteException) { | ||
return failedRecord(record, exception); | ||
|
||
} else if (exception instanceof WriteException.RouteRegexException) { | ||
return failedRecord(record, exception); | ||
|
||
} else if (exception instanceof WriteException.SchemaEvolutionException) { | ||
Throwable cause = exception.getCause(); | ||
if (cause instanceof IllegalArgumentException | ||
|| cause instanceof ValidationException | ||
|| cause instanceof UnsupportedOperationException) { | ||
return failedRecord(record, exception); | ||
} | ||
} else if (exception instanceof WriteException.TableIdentifierException) { | ||
return failedRecord(record, exception); | ||
} | ||
throw exception; | ||
} | ||
|
||
private SinkRecord failedRecord(SinkRecord record, WriteException exception) { | ||
return factory.recordFromConnector(record, exception); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example config with Dead Letter will be very useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs can always be improved. I'll try to take another stab at this.
This is a big feature with a somewhat clunky coinfig API due to config visibility rules in Kafka Connect, so more docs/examples certainly help.