Content-Length: 324637 | pFad | http://github.com/apache/iceberg/commit/e05464dac62f9218cdd82e7d11e21defb0b27d89

B7 fix delete conidition test failures and apply spotless · apache/iceberg@e05464d · GitHub
Skip to content

Commit

Permalink
fix delete conidition test failures and apply spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Ye committed Mar 6, 2023
1 parent 4446d8f commit e05464d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
6 changes: 5 additions & 1 deletion core/src/main/java/org/apache/iceberg/util/SnapshotUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ public static Snapshot latestSnapshot(TableMetadata metadata, String branch) {
* @return schema of the specific snapshot at the given branch
*/
public static Schema snapshotSchema(Table table, String branch) {
return branch == null ? table.schema() : table.schemas().get(table.snapshot(branch).schemaId());
if (branch == null || branch.equals(SnapshotRef.MAIN_BRANCH)) {
return table.schema();
}

return table.schemas().get(table.snapshot(branch).schemaId());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ public void testDeleteWithoutCondition() {

@Test
public void testDeleteUsingMetadataWithComplexCondition() {
Assume.assumeTrue("test".equals(branch));
createAndInitPartitionedTable();

sql("INSERT INTO %s VALUES (1, 'dep1')", queryTarget());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ public void testCommitUnknownException() {
when(spyTable.newRowDelta()).thenReturn(spyNewRowDelta);
SparkTable sparkTable =
branch == null ? new SparkTable(spyTable, false) : new SparkTable(spyTable, branch, false);
;

ImmutableMap<String, String> config =
ImmutableMap.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Set;
import org.apache.iceberg.BaseTable;
import org.apache.iceberg.DataFile;
import org.apache.iceberg.DeleteFiles;
import org.apache.iceberg.FileScanTask;
import org.apache.iceberg.MetadataColumns;
import org.apache.iceberg.PartitionSpec;
Expand Down Expand Up @@ -295,7 +296,8 @@ public boolean canDeleteWhere(Filter[] filters) {
}
}

return canDeleteUsingMetadata(deleteExpr);
boolean result = canDeleteUsingMetadata(deleteExpr);
return result;
}

// a metadata delete is possible iff matching files can be deleted entirely
Expand Down Expand Up @@ -352,11 +354,17 @@ public void deleteWhere(Filter[] filters) {
return;
}

icebergTable
.newDelete()
.set("spark.app.id", sparkSession().sparkContext().applicationId())
.deleteFromRowFilter(deleteExpr)
.commit();
DeleteFiles deleteFiles =
icebergTable
.newDelete()
.set("spark.app.id", sparkSession().sparkContext().applicationId())
.deleteFromRowFilter(deleteExpr);

if (branch != null) {
deleteFiles.toBranch(branch);
}

deleteFiles.commit();
}

@Override
Expand Down

0 comments on commit e05464d

Please sign in to comment.








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/apache/iceberg/commit/e05464dac62f9218cdd82e7d11e21defb0b27d89

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy