This is an automated email from the ASF dual-hosted git repository.
blue pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iceberg.git
The following commit(s) were added to refs/heads/main by this push:
new a97b4ecc4d Revert "Move deleted files to Hadoop trash if configured
(#14501)" (#15386)
a97b4ecc4d is described below
commit a97b4ecc4db52ee2b0ddcecd34219275df002876
Author: Daniel Weeks <[email protected]>
AuthorDate: Mon Feb 23 13:50:23 2026 -0800
Revert "Move deleted files to Hadoop trash if configured (#14501)" (#15386)
This reverts commit 06c1e0a0be75b2dd419b2a97fcb47676cf4da279.
---
.../org/apache/iceberg/hadoop/HadoopFileIO.java | 17 +-----
.../apache/iceberg/hadoop/TestHadoopFileIO.java | 62 ----------------------
2 files changed, 2 insertions(+), 77 deletions(-)
diff --git a/core/src/main/java/org/apache/iceberg/hadoop/HadoopFileIO.java
b/core/src/main/java/org/apache/iceberg/hadoop/HadoopFileIO.java
index 3740f0abda..a4ac5e2ff6 100644
--- a/core/src/main/java/org/apache/iceberg/hadoop/HadoopFileIO.java
+++ b/core/src/main/java/org/apache/iceberg/hadoop/HadoopFileIO.java
@@ -28,11 +28,8 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.LocalFileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.RemoteIterator;
-import org.apache.hadoop.fs.Trash;
-import org.apache.hadoop.hdfs.DistributedFileSystem;
import org.apache.iceberg.exceptions.RuntimeIOException;
import org.apache.iceberg.io.BulkDeletionFailureException;
import org.apache.iceberg.io.DelegateFileIO;
@@ -105,7 +102,7 @@ public class HadoopFileIO implements HadoopConfigurable,
DelegateFileIO {
Path toDelete = new Path(path);
FileSystem fs = Util.getFs(toDelete, getConf());
try {
- deletePath(fs, toDelete, false);
+ fs.delete(toDelete, false /* not recursive */);
} catch (IOException e) {
throw new RuntimeIOException(e, "Failed to delete file: %s", path);
}
@@ -170,7 +167,7 @@ public class HadoopFileIO implements HadoopConfigurable,
DelegateFileIO {
FileSystem fs = Util.getFs(prefixToDelete, getConf());
try {
- deletePath(fs, prefixToDelete, true);
+ fs.delete(prefixToDelete, true /* recursive */);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
@@ -214,16 +211,6 @@ public class HadoopFileIO implements HadoopConfigurable,
DelegateFileIO {
return executorService;
}
- private void deletePath(FileSystem fs, Path toDelete, boolean recursive)
throws IOException {
- Trash trash = new Trash(fs, getConf());
- if ((fs instanceof LocalFileSystem || fs instanceof DistributedFileSystem)
- && trash.isEnabled()) {
- trash.moveToTrash(toDelete);
- } else {
- fs.delete(toDelete, recursive);
- }
- }
-
/**
* This class is a simple adaptor to allow for using Hadoop's RemoteIterator
as an Iterator.
*
diff --git a/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopFileIO.java
b/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopFileIO.java
index b459c7e062..554ed625b9 100644
--- a/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopFileIO.java
+++ b/core/src/test/java/org/apache/iceberg/hadoop/TestHadoopFileIO.java
@@ -18,7 +18,6 @@
*/
package org.apache.iceberg.hadoop;
-import static
org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_TRASH_INTERVAL_KEY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -127,46 +126,6 @@ public class TestHadoopFileIO {
.hasMessageContaining("java.io.FileNotFoundException");
}
- @Test
- public void testDeletePrefixWithTrashEnabled() throws IOException {
- Configuration conf = new Configuration();
- conf.set(FS_TRASH_INTERVAL_KEY, "60");
- fs = FileSystem.getLocal(conf);
-
- hadoopFileIO = new HadoopFileIO(conf);
- Path parent = new Path(tempDir.toURI());
-
- List<Integer> scaleSizes = Lists.newArrayList(1, 1000, 2500);
-
- scaleSizes.parallelStream()
- .forEach(
- scale -> {
- Path scalePath = new Path(parent, Integer.toString(scale));
-
- List<Path> filesCreated = createRandomFiles(scalePath, scale);
- hadoopFileIO.deletePrefix(scalePath.toUri().toString());
-
- // Hadoop filesystem will throw if the path does not exist
- assertThatThrownBy(
- () ->
hadoopFileIO.listPrefix(scalePath.toUri().toString()).iterator())
- .isInstanceOf(UncheckedIOException.class)
- .hasMessageContaining("java.io.FileNotFoundException");
- filesCreated.forEach(
- file -> {
- String fileSuffix =
Path.getPathWithoutSchemeAndAuthority(file).toString();
- String trashPath =
- fs.getTrashRoot(scalePath).toString() + "/Current" +
fileSuffix;
-
assertThat(hadoopFileIO.newInputFile(trashPath).exists()).isTrue();
- });
- });
-
- hadoopFileIO.deletePrefix(parent.toUri().toString());
- // Hadoop filesystem will throw if the path does not exist
- assertThatThrownBy(() ->
hadoopFileIO.listPrefix(parent.toUri().toString()).iterator())
- .isInstanceOf(UncheckedIOException.class)
- .hasMessageContaining("java.io.FileNotFoundException");
- }
-
@Test
public void testDeleteFiles() {
Path parent = new Path(tempDir.toURI());
@@ -177,27 +136,6 @@ public class TestHadoopFileIO {
file ->
assertThat(hadoopFileIO.newInputFile(file.toString()).exists()).isFalse());
}
- @Test
- public void testDeleteFilesWithTrashEnabled() throws IOException {
- Configuration conf = new Configuration();
- conf.set(FS_TRASH_INTERVAL_KEY, "60");
- fs = FileSystem.getLocal(conf);
-
- hadoopFileIO = new HadoopFileIO(conf);
- Path parent = new Path(tempDir.toURI());
- List<Path> filesCreated = createRandomFiles(parent, 10);
- hadoopFileIO.deleteFiles(
-
filesCreated.stream().map(Path::toString).collect(Collectors.toList()));
- filesCreated.forEach(
- file ->
assertThat(hadoopFileIO.newInputFile(file.toString()).exists()).isFalse());
- filesCreated.forEach(
- file -> {
- String fileSuffix =
Path.getPathWithoutSchemeAndAuthority(file).toString();
- String trashPath = fs.getTrashRoot(parent).toString() + "/Current" +
fileSuffix;
- assertThat(hadoopFileIO.newInputFile(trashPath).exists()).isTrue();
- });
- }
-
@Test
public void testDeleteFilesErrorHandling() {
List<String> filesCreated =