Skip to content

Commit

Permalink
Spark: Fix metadata delete check with branches (apache#9102)
Browse files Browse the repository at this point in the history
  • Loading branch information
amogh-jahagirdar authored Nov 19, 2023
1 parent 04d1a9d commit c193de9
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public static Object[][] parameters() {
true,
WRITE_DISTRIBUTION_MODE_NONE,
false,
null,
"test",
DISTRIBUTED
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,8 @@ public void testDeleteWithoutScanningTable() throws Exception {
public void testDeleteFileThenMetadataDelete() throws Exception {
Assume.assumeFalse("Avro does not support metadata delete", fileFormat.equals("avro"));
createAndInitUnpartitionedTable();

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

// MOR mode: writes a delete file as null cannot be deleted by metadata
sql("DELETE FROM %s AS t WHERE t.id IS NULL", commitTarget());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ private boolean canDeleteUsingMetadata(Expression deleteExpr) {
.ignoreResiduals();

if (branch != null) {
scan.useRef(branch);
scan = scan.useRef(branch);
}

try (CloseableIterable<FileScanTask> tasks = scan.planFiles()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ public static List<DataFile> dataFiles(Table table) {
public static List<DataFile> dataFiles(Table table, String branch) {
TableScan scan = table.newScan();
if (branch != null) {
scan.useRef(branch);
scan = scan.useRef(branch);
}

CloseableIterable<FileScanTask> tasks = scan.includeColumnStats().planFiles();
Expand Down

0 comments on commit c193de9

Please sign in to comment.