amogh-jahagirdar commented on code in PR #5379:
URL: https://github.com/apache/iceberg/pull/5379#discussion_r942979030


##########
aws/src/main/java/org/apache/iceberg/aws/s3/S3FileIO.java:
##########
@@ -244,26 +260,33 @@ private void tagFileToDelete(String path, Set<Tag> 
deleteTags) throws S3Exceptio
     client().putObjectTagging(putObjectTaggingRequest);
   }
 
-  private List<String> deleteObjectsInBucket(String bucket, Collection<String> 
objects) {
-    if (!objects.isEmpty()) {
-      List<ObjectIdentifier> objectIds =
-          objects.stream()
-              .map(objectKey -> 
ObjectIdentifier.builder().key(objectKey).build())
-              .collect(Collectors.toList());
-      DeleteObjectsRequest deleteObjectsRequest =
-          DeleteObjectsRequest.builder()
-              .bucket(bucket)
-              .delete(Delete.builder().objects(objectIds).build())
-              .build();
-      DeleteObjectsResponse response = 
client().deleteObjects(deleteObjectsRequest);
-      if (response.hasErrors()) {
-        return response.errors().stream()
-            .map(error -> String.format("s3://%s/%s", bucket, error.key()))
+  private List<String> deleteBatch(String bucket, Collection<String> 
keysToDelete) {
+    List<ObjectIdentifier> objectIds =
+        keysToDelete.stream()
+            .map(key -> ObjectIdentifier.builder().key(key).build())
             .collect(Collectors.toList());
+    DeleteObjectsRequest request =
+        DeleteObjectsRequest.builder()
+            .bucket(bucket)
+            .delete(Delete.builder().objects(objectIds).build())
+            .build();
+    List<String> failures = Lists.newArrayList();
+    try {
+      DeleteObjectsResponse response = client().deleteObjects(request);
+      if (response.hasErrors()) {
+        failures.addAll(
+            response.errors().stream()
+                .map(error -> String.format("s3://%s/%s", request.bucket(), 
error.key()))
+                .collect(Collectors.toList()));
       }
+    } catch (Exception e) {

Review Comment:
   Yeah I think in case of any failure we should surface a BulkDeletionFailure 
at the end. So catching the generic exception allows us to handle any failure, 
treat it as a failure to delete the entire batch, and add that to the failed 
files list. I'm not sure of any other case where we want to surface something 
else. We're logging the specific exception so that folks can debug.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to