Fixed handling of iceberg table created via flink iceberg sink in upsert mode - #98
Open
andrea-rockt wants to merge 1 commit into
Conversation
|
Hi @andrea-rockt. Thank you for reaching out and providing this extensive commit statement. Over the past 2-3 weeks our team has discussed this internally as we've coincidentally hit both of the bugs you state in this fix. The sequence number issue is fixed now. The null equality Id's should be merged this week. I'll report back on whether we can have the equality id issue in 26.1.0 in prep for the next oss release. Thanks again! We appreciate it. |
|
Hi @andrea-rockt , Updating once more to confirm that both of these bugs you've addressed will be part of 26.1.0 release. Thanks for the contribution! Best, |
Author
|
Thanks for the update @Jordano-Dremio much appreciated, thanks again for the support 💪 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue summary
Dremio appears to not correctly handle tables written with the flink iceberg sink in upsert mode.
The flink iceberg sink utilizes a mix of positional deletes (for changes happening inside the same checkpoint interval to the same key) and equality deletes (only for the first change to a key during a checkpoint interval, to not scan the full table to generate positional delete )
Spark is able to read the table correctly
flink iceberg sink and spark iceberg reader are part of the official iceberg codebase so i expect coherency between the two implementations
The sample table used in this PR is provided in this pull request content
Libraries version
The problem happens with all the releases of flink iceberg runtime
Writer application
Table construction timeline
t1/flink - Initial load of table
t2/flink - Performs checkpoint 1
t3/spark - query snapshot
t4/database - deadpool updated 3 times
t5/flink - replicate changes to iceberg table
t6/flink - Performs checkpoint 2
t7/spark - Query snapshot of checkpoint 2
t8/database - Removed batman
t9/database - Inserted Aquaman
t10/database - Updated tony stark
t11/flink - Replicate changes
t12/flink - Perform checkpoint 3
t13/spark - Query snapshot after checkpoint
This state matches the database state
Accessing the table via dremio
Dremio versions tried (docker deployment)
Physical plan
TABLE IS EMPTY, equality delete files are applied to all data files in snapshots
Steps taken to produce this patch
Extracondition of hash join between data and delete files appears to be wrong.
Iceberg documentation says that delete files should be applied to datafiles where sequenceNumber is strictly less than dremio appears to use less than equal (it is a bit ambiguous in wording)
Dremio Patched to use less than operator (instead of less than equal) in extra hash join condition when associating datafiles to the respective equality and positional delete files
Equality delete fils are now applied as expected but positional delete files get skipped
Dremio patched to use less than as hash join predicate on equality deletes and less_than_equal on positional deletes
Dremio result matches the result of SPARK
Additional notes
Once the hash join condition was changed to distinguish between positional and equality delete files the
IcebergDeleteFileAggTableFunctionbroke, when copying data from the internal accumulator to the output vector the innerequalityIdslist was populated with nulls instead of the correct values, unless theequalityIdslength was the same for each entry (it is null for positional delete, no list at all)I believe to have fixed the vectors handling and properly allocated memory for the accumulator vector but i don't have sufficient expertise to judge it