Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ private boolean canContainDeletedFiles(ManifestFile manifest) {
return canContainExpressionDeletes || canContainDroppedPartitions || canContainDroppedFiles || canContainDropBySeq;
}

@SuppressWarnings("CollectionUndefinedEquality")
@SuppressWarnings({"CollectionUndefinedEquality", "CyclomaticComplexity"})
private boolean manifestHasDeletedFiles(PartitionAndMetricsEvaluator evaluator, ManifestReader<F> reader) {
boolean isDelete = reader.isDeleteManifestReader();
boolean hasDeletedFiles = false;
Expand All @@ -359,7 +359,13 @@ private boolean manifestHasDeletedFiles(PartitionAndMetricsEvaluator evaluator,
boolean fileDelete = deletePaths.contains(file.path()) ||
dropPartitions.contains(file.specId(), file.partition()) ||
(isDelete && entry.sequenceNumber() > 0 && entry.sequenceNumber() < minSequenceNumber);

if (fileDelete || evaluator.rowsMightMatch(file)) {
if (!fileDelete && !file.content().equals(FileContent.DATA) && !evaluator.rowsMustMatch(file)) {
Comment thread
szehon-ho marked this conversation as resolved.
Outdated
// not all DeleteFiles removal can be handled by metadata operation, skip if it cannot
continue;
}

ValidationException.check(
fileDelete || evaluator.rowsMustMatch(file),
"Cannot delete file where some, but not all, rows match filter %s: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,23 @@ public void removeTables() {
sql("DROP TABLE IF EXISTS deleted_dep");
}

@Test
public void testDeleteFileThenMetadataDelete() {
createAndInitUnpartitionedTable();

sql("INSERT INTO TABLE %s VALUES (1, 'hr'), (2, 'hardware'), (null, 'hr')", tableName);

// MOR mode: writes a delete file as null cannot be deleted by metadata
sql("DELETE FROM %s AS t WHERE t.id IS NULL", tableName);
Comment thread
szehon-ho marked this conversation as resolved.

// Metadata Delete
sql("DELETE FROM %s AS t WHERE t.id = 1", tableName);
Comment thread
szehon-ho marked this conversation as resolved.

assertEquals("Should have expected rows",
ImmutableList.of(row(2, "hardware")),
sql("SELECT * FROM %s ORDER BY id", tableName));
}

@Test
public void testDeleteWithFalseCondition() {
createAndInitUnpartitionedTable();
Expand Down