Skip to content

Commit

Permalink
Fix correctness issue when writing deletion vectors in Delta Lake
Browse files Browse the repository at this point in the history
  • Loading branch information
ebyhr committed Jan 8, 2025
1 parent ae84dfd commit 24e6382
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ private Slice writeDeletionVector(
{
String tablePath = rootTableLocation.toString();
String sourceRelativePath = relativePath(tablePath, sourcePath);
DeletionVectorEntry oldDeletionVector = deletionVectors.get(sourceRelativePath);

DeletionVectorEntry deletionVectorEntry;
try {
Expand All @@ -426,7 +427,7 @@ private Slice writeDeletionVector(
deletion.partitionValues,
readStatistics(parquetMetadata, dataColumns, rowCount),
Optional.of(deletionVectorEntry));
DeltaLakeMergeResult result = new DeltaLakeMergeResult(deletion.partitionValues, Optional.of(sourceRelativePath), Optional.empty(), Optional.of(newFileInfo));
DeltaLakeMergeResult result = new DeltaLakeMergeResult(deletion.partitionValues, Optional.of(sourceRelativePath), Optional.ofNullable(oldDeletionVector), Optional.of(newFileInfo));
return utf8Slice(mergeResultJsonCodec.toJson(result));
}
catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,16 @@ public void testDeletionVectorsRandomPrefix()
assertUpdate("DROP TABLE " + tableName);
}

@Test
void testDeletionVectorsRepeat()
{
try (TestTable table = newTrinoTable("test_dv", "(x int) WITH (deletion_vectors_enabled = true)", List.of("1", "2", "3"))) {
assertUpdate("DELETE FROM " + table.getName() + " WHERE x = 1", 1);
assertUpdate("DELETE FROM " + table.getName() + " WHERE x = 2", 1);
assertThat(query("SELECT * FROM " + table.getName())).matches("VALUES 3");
}
}

@Test
public void testUnsupportedVacuumDeletionVectors()
throws Exception
Expand Down

0 comments on commit 24e6382

Please sign in to comment.