-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix error: java.lang.IllegalArgumentException: Can not create a Path from an empty string #771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,6 +61,7 @@ | |
| import java.util.stream.Collectors; | ||
| import org.apache.avro.generic.GenericRecord; | ||
| import org.apache.avro.generic.IndexedRecord; | ||
| import org.apache.commons.lang.StringUtils; | ||
| import org.apache.hadoop.fs.FileStatus; | ||
| import org.apache.hadoop.fs.FileSystem; | ||
| import org.apache.hadoop.fs.Path; | ||
|
|
@@ -315,7 +316,10 @@ protected Map<FileStatus, Boolean> deleteCleanedFiles(Map<FileStatus, Boolean> r | |
| throws IOException { | ||
| logger.info("Cleaning path " + partitionPath); | ||
| FileSystem fs = getMetaClient().getFs(); | ||
| FileStatus[] toBeDeleted = fs.listStatus(new Path(config.getBasePath(), partitionPath), filter); | ||
| // FileStatus[] toBeDeleted = fs.listStatus(new Path(config.getBasePath(), partitionPath), filter); | ||
| FileStatus[] toBeDeleted = StringUtils.isBlank(partitionPath) | ||
| ? fs.listStatus(new Path(config.getBasePath()), filter) : | ||
| fs.listStatus(new Path(config.getBasePath(), partitionPath), filter); | ||
| for (FileStatus file : toBeDeleted) { | ||
| boolean success = fs.delete(file.getPath(), false); | ||
| results.put(file, success); | ||
|
|
@@ -340,7 +344,10 @@ protected Map<FileStatus, Boolean> deleteCleanedFiles(Map<FileStatus, Boolean> r | |
| } | ||
| return false; | ||
| }; | ||
| FileStatus[] toBeDeleted = fs.listStatus(new Path(config.getBasePath(), partitionPath), filter); | ||
| // FileStatus[] toBeDeleted = fs.listStatus(new Path(config.getBasePath(), partitionPath), filter); | ||
| FileStatus[] toBeDeleted = StringUtils.isBlank(partitionPath) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
| ? fs.listStatus(new Path(config.getBasePath()), filter) : | ||
| fs.listStatus(new Path(config.getBasePath(), partitionPath), filter); | ||
| for (FileStatus file : toBeDeleted) { | ||
| boolean success = fs.delete(file.getPath(), false); | ||
| results.put(file, success); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,8 @@ | |
| import java.util.function.Predicate; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import org.apache.commons.lang.StringUtils; | ||
| import org.apache.hadoop.fs.FileStatus; | ||
| import org.apache.hadoop.fs.Path; | ||
| import org.apache.log4j.LogManager; | ||
|
|
@@ -216,7 +218,9 @@ private void ensurePartitionLoadedCorrectly(String partition) { | |
| log.info("Building file system view for partition (" + partitionPathStr + ")"); | ||
|
|
||
| // Create the path if it does not exist already | ||
| Path partitionPath = FSUtils.getPartitionPath(metaClient.getBasePath(), partitionPathStr); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't FSUtils.getPartitionPath working ? Its better to use the method consistently in all places wherever we see
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
| Path partitionPath = StringUtils.isBlank(partitionPathStr) | ||
| ? new Path(metaClient.getBasePath()) : new Path(metaClient.getBasePath(), partitionPathStr); | ||
| // Path partitionPath = new Path(metaClient.getBasePath(), partitionPathStr); | ||
| FSUtils.createPathIfNotExists(metaClient.getFs(), partitionPath); | ||
| long beginLsTs = System.currentTimeMillis(); | ||
| FileStatus[] statuses = metaClient.getFs().listStatus(partitionPath); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FSUtils.getPartitionPath below is supposed to handle this.Can you use that method directly everywhere to be consistent. If it does not work, can you fix the method ?
public static Path getPartitionPath(Path basePath, String partitionPath) {
// FOr non-partitioned table, return only base-path
return ((partitionPath == null) || (partitionPath.isEmpty())) ? basePath :
new Path(basePath, partitionPath);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bvaradar
When I rebuilt hoodie with spark-2.3.3 and parquet-1.8.2 and avro-1.8.2 and run test class
HoodieJavaApp, it reported errorCan not create a Path from an empty string. But spark-2.1.0 didn't. Here is my version:I think I can write a common method in FsUtils.