Skip to content

Commit ed1fa57

Browse files
authored
[HUDI-9681] Remove mkdir in partition listing and add try catch to listStatus of partition (#13739)
1 parent 39c2f81 commit ed1fa57

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,9 +398,7 @@ protected Map<Pair<String, StoragePath>, List<StoragePathInfo>> listPartitions(
398398
pathInfoMap.put(partitionPair,
399399
metaClient.getStorage().listDirectEntries(absolutePartitionPath));
400400
} catch (IOException e) {
401-
// Create the path if it does not exist already
402401
if (!metaClient.getStorage().exists(absolutePartitionPath)) {
403-
metaClient.getStorage().createDirectory(absolutePartitionPath);
404402
pathInfoMap.put(partitionPair, Collections.emptyList());
405403
} else {
406404
// in case the partition path was created by another caller
@@ -471,9 +469,7 @@ protected List<StoragePathInfo> listPartition(StoragePath partitionPath) throws
471469
try {
472470
return metaClient.getStorage().listDirectEntries(partitionPath);
473471
} catch (IOException e) {
474-
// Create the path if it does not exist already
475472
if (!metaClient.getStorage().exists(partitionPath)) {
476-
metaClient.getStorage().createDirectory(partitionPath);
477473
return Collections.emptyList();
478474
} else {
479475
// in case the partition path was created by another caller

hudi-common/src/main/java/org/apache/hudi/metadata/FileSystemBackedTableMetadata.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import org.apache.hudi.storage.StoragePath;
4545
import org.apache.hudi.storage.StoragePathInfo;
4646

47+
import java.io.FileNotFoundException;
4748
import java.io.IOException;
4849
import java.util.ArrayList;
4950
import java.util.Collection;
@@ -52,6 +53,7 @@
5253
import java.util.Map;
5354
import java.util.concurrent.CopyOnWriteArrayList;
5455
import java.util.stream.Collectors;
56+
import java.util.stream.Stream;
5557

5658
/**
5759
* Implementation of {@link HoodieTableMetadata} based file-system-backed table metadata.
@@ -177,7 +179,12 @@ private List<String> getPartitionPathWithPathPrefixUsingFilterExpression(String
177179
"Listing all partitions with prefix " + relativePathPrefix);
178180
// Need to use serializable file status here, see HUDI-5936
179181
List<StoragePathInfo> dirToFileListing = engineContext.flatMap(pathsToList, path -> {
180-
return getStorage().listDirectEntries(path).stream();
182+
try {
183+
return getStorage().listDirectEntries(path).stream();
184+
} catch (FileNotFoundException e) {
185+
// The partition may have been cleaned.
186+
return Stream.empty();
187+
}
181188
}, listingParallelism);
182189
pathsToList.clear();
183190

0 commit comments

Comments
 (0)