From bd9cf565818e370b75b9e352abdcbbde701a9d89 Mon Sep 17 00:00:00 2001 From: Sagar Sumit Date: Mon, 15 Nov 2021 20:40:18 +0530 Subject: [PATCH] [HUDI-2743] Assume path exists and defer fs.exists() in AbstractTableFileSystemView Add a unit test Assume partition exists and create only when not found --- .../table/view/AbstractTableFileSystemView.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java index eca3718f18a03..58c71652adc76 100644 --- a/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java +++ b/hudi-common/src/main/java/org/apache/hudi/common/table/view/AbstractTableFileSystemView.java @@ -315,13 +315,16 @@ private void ensurePartitionLoadedCorrectly(String partition) { * @throws IOException */ protected FileStatus[] listPartition(Path partitionPath) throws IOException { - // Create the path if it does not exist already - if (!metaClient.getFs().exists(partitionPath)) { - metaClient.getFs().mkdirs(partitionPath); - return new FileStatus[0]; - } else { + try { return metaClient.getFs().listStatus(partitionPath); + } catch (IOException e) { + // Create the path if it does not exist already + if (!metaClient.getFs().exists(partitionPath)) { + metaClient.getFs().mkdirs(partitionPath); + return new FileStatus[0]; + } } + throw new HoodieIOException(String.format("Failed to list partition path: %s", partitionPath)); } /**