-
Notifications
You must be signed in to change notification settings - Fork 3k
Core: Fix deleted data files validation in OverwriteFiles #4303
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 |
|---|---|---|
|
|
@@ -35,7 +35,7 @@ public class BaseOverwriteFiles extends MergingSnapshotProducer<OverwriteFiles> | |
| private Long startingSnapshotId = null; | ||
| private Expression conflictDetectionFilter = null; | ||
| private boolean validateNewDataFiles = false; | ||
| private boolean validateNewDeleteFiles = false; | ||
| private boolean validateNewDeletes = false; | ||
|
|
||
| protected BaseOverwriteFiles(String tableName, TableOperations ops) { | ||
| super(tableName, ops); | ||
|
|
@@ -98,7 +98,7 @@ public OverwriteFiles validateNoConflictingData() { | |
|
|
||
| @Override | ||
| public OverwriteFiles validateNoConflictingDeletes() { | ||
| this.validateNewDeleteFiles = true; | ||
| this.validateNewDeletes = true; | ||
| failMissingDeletePaths(); | ||
| return this; | ||
| } | ||
|
|
@@ -134,10 +134,11 @@ protected void validate(TableMetadata base) { | |
| validateAddedDataFiles(base, startingSnapshotId, dataConflictDetectionFilter()); | ||
| } | ||
|
|
||
| if (validateNewDeleteFiles) { | ||
| if (validateNewDeletes) { | ||
| if (rowFilter() != Expressions.alwaysFalse()) { | ||
| Expression filter = conflictDetectionFilter != null ? conflictDetectionFilter : rowFilter(); | ||
| validateNoNewDeleteFiles(base, startingSnapshotId, filter); | ||
| validateDeletedDataFiles(base, startingSnapshotId, filter); | ||
|
Member
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. 👍 |
||
| } | ||
|
|
||
| if (deletedDataFiles.size() > 0) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -747,6 +747,60 @@ public void testConcurrentConflictingPositionDeletesOverwriteByFilter() { | |
| overwrite::commit); | ||
| } | ||
|
|
||
| @Test | ||
| public void testConcurrentConflictingDataFileDeleteOverwriteByFilter() { | ||
|
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 test would previously fail as the commit would succeed.
Member
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. The error here is because file 2 is both modified and deleted correct?
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, we concurrently removed data from a partition what we are trying to overwrite. |
||
| Assert.assertNull("Should be empty table", table.currentSnapshot()); | ||
|
|
||
| table.newAppend() | ||
| .appendFile(FILE_DAY_1) | ||
| .appendFile(FILE_DAY_2) | ||
| .commit(); | ||
|
|
||
| Snapshot firstSnapshot = table.currentSnapshot(); | ||
|
|
||
| OverwriteFiles overwrite = table.newOverwrite() | ||
| .overwriteByRowFilter(EXPRESSION_DAY_2) | ||
| .addFile(FILE_DAY_2_MODIFIED) | ||
| .validateFromSnapshot(firstSnapshot.snapshotId()) | ||
| .validateNoConflictingData() | ||
| .validateNoConflictingDeletes(); | ||
|
|
||
| table.newOverwrite() | ||
| .deleteFile(FILE_DAY_2) | ||
| .commit(); | ||
|
|
||
| AssertHelpers.assertThrows("Should reject commit", | ||
| ValidationException.class, "Found conflicting deleted files", | ||
| overwrite::commit); | ||
| } | ||
|
|
||
| @Test | ||
| public void testConcurrentNonConflictingDataFileDeleteOverwriteByFilter() { | ||
| Assert.assertNull("Should be empty table", table.currentSnapshot()); | ||
|
|
||
| table.newAppend() | ||
| .appendFile(FILE_DAY_1) | ||
| .appendFile(FILE_DAY_2) | ||
| .commit(); | ||
|
|
||
| Snapshot firstSnapshot = table.currentSnapshot(); | ||
|
|
||
| OverwriteFiles overwrite = table.newOverwrite() | ||
|
Member
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. While this one is alright because file 2 is modified, but file 1 is deleted. |
||
| .overwriteByRowFilter(EXPRESSION_DAY_2) | ||
| .addFile(FILE_DAY_2_MODIFIED) | ||
| .validateFromSnapshot(firstSnapshot.snapshotId()) | ||
| .validateNoConflictingData() | ||
| .validateNoConflictingDeletes(); | ||
|
|
||
| table.newOverwrite() | ||
| .deleteFile(FILE_DAY_1) | ||
| .commit(); | ||
|
|
||
| overwrite.commit(); | ||
|
|
||
| validateTableFiles(table, FILE_DAY_2_MODIFIED); | ||
| } | ||
|
|
||
| @Test | ||
| public void testConcurrentNonConflictingPositionDeletes() { | ||
| Assume.assumeTrue(formatVersion == 2); | ||
|
|
||
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.
Why the rename here?
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.
Cause we not only validate added delete files but also deleted data files. We have two types of deletes to cover.