-
Notifications
You must be signed in to change notification settings - Fork 3k
API, Core: Don't persist useless file and position bounds #8360
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
Merged
aokolnychyi
merged 2 commits into
apache:master
from
aokolnychyi:ignore-file-stats-position-deletes
Aug 22, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -229,6 +229,17 @@ public void testPositionDeleteWriter() throws IOException { | |
| DeleteFile deleteFile = result.first(); | ||
| CharSequenceSet referencedDataFiles = result.second(); | ||
|
|
||
| if (fileFormat == FileFormat.AVRO) { | ||
| Assert.assertNull(deleteFile.lowerBounds()); | ||
| Assert.assertNull(deleteFile.upperBounds()); | ||
| } else { | ||
| Assert.assertEquals(1, referencedDataFiles.size()); | ||
| Assert.assertEquals(2, deleteFile.lowerBounds().size()); | ||
|
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. Should this also assert that
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. I'll add a check. |
||
| Assert.assertTrue(deleteFile.lowerBounds().containsKey(DELETE_FILE_PATH.fieldId())); | ||
| Assert.assertEquals(2, deleteFile.upperBounds().size()); | ||
| Assert.assertTrue(deleteFile.upperBounds().containsKey(DELETE_FILE_PATH.fieldId())); | ||
| } | ||
|
|
||
| // verify the written delete file | ||
| GenericRecord deleteRecord = GenericRecord.create(DeleteSchemaUtil.pathPosSchema()); | ||
| List<Record> expectedDeletes = | ||
|
|
@@ -302,6 +313,53 @@ public void testPositionDeleteWriterWithRow() throws IOException { | |
| Assert.assertEquals("Records should match", toSet(expectedRows), actualRowSet("*")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testPositionDeleteWriterMultipleDataFiles() throws IOException { | ||
| FileWriterFactory<T> writerFactory = newWriterFactory(table.schema()); | ||
|
|
||
| // write two data files | ||
| DataFile dataFile1 = writeData(writerFactory, dataRows, table.spec(), partition); | ||
| DataFile dataFile2 = writeData(writerFactory, dataRows, table.spec(), partition); | ||
|
|
||
| // write a position delete file referencing both | ||
| List<PositionDelete<T>> deletes = | ||
| ImmutableList.of( | ||
| positionDelete(dataFile1.path(), 0L, null), | ||
| positionDelete(dataFile1.path(), 2L, null), | ||
| positionDelete(dataFile2.path(), 4L, null)); | ||
| Pair<DeleteFile, CharSequenceSet> result = | ||
| writePositionDeletes(writerFactory, deletes, table.spec(), partition); | ||
| DeleteFile deleteFile = result.first(); | ||
| CharSequenceSet referencedDataFiles = result.second(); | ||
|
|
||
| // verify the written delete file has NO lower and upper bounds | ||
| Assert.assertEquals(2, referencedDataFiles.size()); | ||
| Assert.assertNull(deleteFile.lowerBounds()); | ||
| Assert.assertNull(deleteFile.upperBounds()); | ||
|
|
||
| // commit the data and delete files | ||
| table | ||
| .newRowDelta() | ||
| .addRows(dataFile1) | ||
| .addRows(dataFile2) | ||
| .addDeletes(deleteFile) | ||
| .validateDataFilesExist(referencedDataFiles) | ||
| .validateDeletedFiles() | ||
| .commit(); | ||
|
|
||
| // verify the delete file is applied correctly | ||
| List<T> expectedRows = | ||
| ImmutableList.of( | ||
| toRow(2, "aaa"), | ||
| toRow(4, "aaa"), | ||
| toRow(5, "aaa"), | ||
| toRow(1, "aaa"), | ||
| toRow(2, "aaa"), | ||
| toRow(3, "aaa"), | ||
| toRow(4, "aaa")); | ||
| Assert.assertEquals("Records should match", toSet(expectedRows), actualRowSet("*")); | ||
| } | ||
|
|
||
| private DataFile writeData( | ||
| FileWriterFactory<T> writerFactory, List<T> rows, PartitionSpec spec, StructLike partitionKey) | ||
| throws IOException { | ||
|
|
||
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.
Looks like the idea is only to drop the bounds for
_fileand_pos? I guess that would mean that we keep data column ranges that might be used for filtering?Uh oh!
There was an error while loading. Please reload this page.
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.
I am not aware of any engines that persist deleted rows but I opted in for an incremental change in behavior to be safe.