1
0

Create the partition path if it does not exist when listing data files in a partition

This commit is contained in:
Prasanna Rajaperumal
2017-03-27 14:49:26 -07:00
committed by vinoth chandar
parent e3b273e9fd
commit 77e54e78f8
2 changed files with 8 additions and 0 deletions

View File

@@ -117,6 +117,8 @@ public class HoodieTableFileSystemView implements TableFileSystemView, Serializa
protected FileStatus[] listDataFilesInPartition(String partitionPathStr) {
Path partitionPath = new Path(metaClient.getBasePath(), partitionPathStr);
try {
// Create the path if it does not exist already
FSUtils.createPathIfNotExists(fs, partitionPath);
return fs.listStatus(partitionPath, path -> path.getName()
.contains(metaClient.getTableConfig().getROFileFormat().getFileExtension()));
} catch (IOException e) {

View File

@@ -349,4 +349,10 @@ public class FSUtils {
}
});
}
public static void createPathIfNotExists(FileSystem fs, Path partitionPath) throws IOException {
if(!fs.exists(partitionPath)) {
fs.mkdirs(partitionPath);
}
}
}