-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Core: Disallow adding and removing the same file in a rewrite files commit #17359
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -152,5 +152,12 @@ private void validateReplacedAndAddedFiles() { | |
| Preconditions.checkArgument( | ||
| deletesDeleteFiles() || !addsDeleteFiles(), | ||
| "Delete files to add must be empty because there's no delete file to be rewritten"); | ||
|
|
||
| for (DataFile added : addedDataFiles()) { | ||
| Preconditions.checkArgument( | ||
| !replacedDataFiles.contains(added), | ||
| "Cannot add and delete the same file in the same rewrite: %s", | ||
| added.location()); | ||
| } | ||
|
Comment on lines
+156
to
+161
Contributor
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. I am wondering if this is the right place to place the guard, if the goal is to prevent the same file being added and removed in the same snapshot? I think both overwrite-files and row-delta can be abused in a way to achieve the same goal. On a separate note, knowing this produce incorrect result for the change tracking detection, sometimes such surgical operation can be helpful for stats backfill as to rectify a previously written file with incorrect column level stats, want to see if we shall encourage to use dedicated repair actions such as proposed in #10784
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. Yeah I was looking at this in the interim, I think you're right that Overwrite and Row Delta technically allow this and we should block them too.
Yup! I think rewriting manifests (just like Repair would do) is the right way. After some thought, I don't think updating these operations to infer that add + remove = existing is the right thing to do because I think these APIs have largely been designed around the fact that added = "something new", and removed = "something that existed and we need to remove". |
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -172,6 +172,22 @@ public void testDeleteOnly() { | |||||||||||||||||||||||
| .hasMessage("Files to delete cannot be empty"); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @TestTemplate | ||||||||||||||||||||||||
| public void addingAndDeletingSameFileDisallowed() { | ||||||||||||||||||||||||
|
Contributor
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. I think we might also need to fix a few other tests, namely Lines 1041 to 1051 in 6bfb510
|
||||||||||||||||||||||||
| assertThat(listManifestFiles()).isEmpty(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| commit(table, table.newAppend().appendFile(FILE_A).appendFile(FILE_B), branch); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| assertThatThrownBy( | ||||||||||||||||||||||||
| () -> | ||||||||||||||||||||||||
| apply( | ||||||||||||||||||||||||
| table.newRewrite().rewriteFiles(Sets.newSet(FILE_A), Sets.newSet(FILE_A)), | ||||||||||||||||||||||||
| branch)) | ||||||||||||||||||||||||
| .isInstanceOf(IllegalArgumentException.class) | ||||||||||||||||||||||||
| .hasMessage( | ||||||||||||||||||||||||
| "Cannot add and delete the same file in the same rewrite: " + FILE_A.location()); | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @TestTemplate | ||||||||||||||||||||||||
| public void testDeleteWithDuplicateEntriesInManifest() { | ||||||||||||||||||||||||
| assertThat(listManifestFiles()).isEmpty(); | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.