-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Flink - Fix incorrect / old row being written into delta files when using upsert mode #4364
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
Merged
rdblue
merged 8 commits into
apache:master
from
kbendick:fix-flink-upsert-delta-file-writer
Mar 28, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
54af1ba
Flink - Fix incorrect row being written for delta files when using up…
kbendick 579dc23
PR feedback
kbendick 089e7e0
Remove duplicated test line
kbendick 40f83dc
Add in tests that show breaking upserts when non-pk field is changeed…
kbendick b8fac1a
Remove to only the one test that fails because of the bad key selecti…
kbendick ed33c77
Condense test down to the minimum needed
kbendick 8c443fa
Revert unnecessary changes in TestTaskEqualityDeltaWriter
kbendick 3d0c68a
Remove unrelated test
kbendick 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 hidden or 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 |
|---|---|---|
|
|
@@ -140,6 +140,8 @@ subprojects { | |
| } | ||
| }) | ||
|
|
||
| maxHeapSize = "1500m" | ||
|
|
||
| testLogging { | ||
| events "failed" | ||
| exceptionFormat "full" | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -35,6 +35,8 @@ | |
| import org.apache.iceberg.io.TaskWriter; | ||
| import org.apache.iceberg.io.UnpartitionedWriter; | ||
| import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Sets; | ||
| import org.apache.iceberg.types.TypeUtil; | ||
| import org.apache.iceberg.util.ArrayUtil; | ||
|
|
||
| public class RowDataTaskWriterFactory implements TaskWriterFactory<RowData> { | ||
|
|
@@ -69,8 +71,13 @@ public RowDataTaskWriterFactory(Table table, | |
|
|
||
| if (equalityFieldIds == null || equalityFieldIds.isEmpty()) { | ||
| this.appenderFactory = new FlinkAppenderFactory(schema, flinkSchema, table.properties(), spec); | ||
| } else if (upsert) { | ||
| // In upsert mode, only the new row is emitted using INSERT row kind. Therefore, any column of the inserted row | ||
| // may differ from the deleted row other than the primary key fields, and the delete file must contain values | ||
| // that are correct for the deleted row. Therefore, only write the equality delete fields. | ||
| this.appenderFactory = new FlinkAppenderFactory(schema, flinkSchema, table.properties(), spec, | ||
| ArrayUtil.toIntArray(equalityFieldIds), TypeUtil.select(schema, Sets.newHashSet(equalityFieldIds)), null); | ||
| } else { | ||
| // TODO provide the ability to customize the equality-delete row schema. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment seems worth removing, as not having the right equality-delete row schema can cause correctness issues. |
||
| this.appenderFactory = new FlinkAppenderFactory(schema, flinkSchema, table.properties(), spec, | ||
| ArrayUtil.toIntArray(equalityFieldIds), schema, null); | ||
| } | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.