-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat: implement support for append_dedup in iceberg dest #48731
Merged
Merged
Changes from 1 commit
Commits
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 |
---|---|---|
|
@@ -11,13 +11,15 @@ | |
import org.apache.iceberg.PartitionSpec; | ||
import org.apache.iceberg.Schema; | ||
import org.apache.iceberg.StructLike; | ||
import org.apache.iceberg.data.GenericRecord; | ||
import org.apache.iceberg.data.InternalRecordWrapper; | ||
import org.apache.iceberg.data.Record; | ||
import org.apache.iceberg.io.BaseTaskWriter; | ||
import org.apache.iceberg.io.FileAppenderFactory; | ||
import org.apache.iceberg.io.FileIO; | ||
import org.apache.iceberg.io.OutputFileFactory; | ||
import org.apache.iceberg.types.TypeUtil; | ||
import org.apache.iceberg.types.Types; | ||
|
||
/** | ||
* Implementation of the Iceberg {@link BaseTaskWriter} that handles delta-based updates (insert, | ||
|
@@ -57,16 +59,26 @@ public InternalRecordWrapper wrapper() { | |
return wrapper; | ||
} | ||
|
||
public Record constructIdentifierRecord(Record row) { | ||
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. Nit: does this need to be public? |
||
final GenericRecord recordWithIds = GenericRecord.create(deleteSchema); | ||
|
||
for (final Types.NestedField idField : deleteSchema.columns()) { | ||
recordWithIds.setField(idField.name(), row.getField(idField.name())); | ||
} | ||
|
||
return recordWithIds; | ||
} | ||
|
||
@Override | ||
public void write(final Record row) throws IOException { | ||
final RowDataDeltaWriter writer = route(row); | ||
final Operation rowOperation = getOperation(row); | ||
if (rowOperation == Operation.INSERT) { | ||
writer.write(row); | ||
} else if (rowOperation == Operation.DELETE) { | ||
writer.deleteKey(row); | ||
writer.deleteKey(constructIdentifierRecord(row)); | ||
} else { | ||
writer.deleteKey(row); | ||
writer.deleteKey(constructIdentifierRecord(row)); | ||
writer.write(row); | ||
} | ||
} | ||
|
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
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
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.
fyi we tried enforcing PK requiredness at one point and it caused a lot of problems (there's a surprising number of sources that emit null PKs). If iceberg supports null values in a partition key, we should do that instead
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.
It just wont allow you to mark a field as an identifier field if its nullable. Only non-nullable fields can be identifier fields
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.
ugh. I think we Officially Support composite PKs with nullable fields #31926 (see also slack #p0-primay-keys-cannot-be-null)
so that's going to be awkward