-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Core: Classify RowDelta with data files only as APPEND #14581
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
Open
mxm
wants to merge
1
commit into
apache:main
Choose a base branch
from
mxm:overwrite-to-append
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.
+28
−0
Open
Changes from all commits
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 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
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.
Based on the discussion here, I think this should be enough:
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.
thinking of a case like this, let's say engine wanna delete a record from a file which just had one record in that case an engine might just optimize by saying lets remove the whole file instead of producing a delete ? in this case condition like below protects us :
my understanding is we do support support removing data file in row delta post this
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.
Good point @singhpk234!
In this case the other condition is bugous:
We could add back data with
removeDeletes.To make things even more problematic, in V3 we will have DV updates which is likely a
deleteDeleteFile(DV1)+ anaddDeleteFile(DV2). But nothing guarantees in this case that only new deletes happen. Theoretically this could bring back new records.So this means that @mxm's change is correct, but likely the other path where we fall back to
DataOperations.DELETEis problematicThere 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.
Thanks for the review @singhpk234 and @pvary! Should we change the DELETE path to something like:
Or do you prefer to do this in a separate PR? Originally, this PR is meant to optimize the APPEND case only.
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.
For V2 tables, the condition above works correctly for deletes. However, for V3 tables, if there are already deletes for a data file (i.e., an existing DV), we always remove the old DV and add a new one. This means the condition above is never triggered. On the other hand, we typically don’t re-add rows, so the DELETE operation remains the correct outcome.
My main concern with changing this behavior is that it could be unexpected for users. That’s why I’d prefer to separate the two cases.
In the meantime, if you have some time, could you please test my theory? (Totally understand if you’re busy—I’m just hopeful 😄)
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.
Indeed, it seems rare that we would delete a delete file to resurrect deleted data, but you are right about V3+ DV delete files triggering the above condition due to removing the old delete file and adding the rewritten one, e.g.:
iceberg/spark/v4.0/spark/src/main/java/org/apache/iceberg/spark/source/SparkPositionDeltaWrite.java
Line 232 in 571b696
Maybe we just leave things as-is for DELETE? My intention anyways was to fix the APPEND case :)