-
Notifications
You must be signed in to change notification settings - Fork 28k
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
[SPARK-20408][SQL] Get the glob path in parallel to reduce resolve relation time #17702
Changes from all commits
c4a68b3
4f0cbfa
d1724b1
169a80a
b8a28eb
dc373ae
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 |
---|---|---|
|
@@ -252,6 +252,18 @@ class SparkHadoopUtil extends Logging { | |
if (isGlobPath(pattern)) globPath(fs, pattern) else Seq(pattern) | ||
} | ||
|
||
def expandGlobPath(fs: FileSystem, pattern: Path): Seq[String] = { | ||
val arr = pattern.toString.split("/") | ||
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. we should not parse the path string ourselves, it's too risky, we may miss some special cases like windows path, escape character, etc. Let's take a look at 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. Thanks for your reply, agree with you. |
||
val firstIdx = arr.indexWhere(_.exists("{}[]*?\\".toSet.contains)) | ||
if (isGlobPath(pattern) && firstIdx != arr.length - 1) { | ||
val parentPath = arr.slice(0, firstIdx + 1).mkString("/") | ||
Option(fs.globStatus(new Path(parentPath))).map{ statuses => | ||
statuses.map(_.getPath.makeQualified(fs.getUri, fs.getWorkingDirectory).toString | ||
+ "/" + arr.slice(firstIdx + 1, arr.length).mkString("/")).toSeq | ||
}.getOrElse(Seq.empty[String]) | ||
} else Seq(pattern.toString) | ||
} | ||
|
||
/** | ||
* Lists all the files in a directory with the specified prefix, and does not end with the | ||
* given suffix. The returned {{FileStatus}} instances are sorted by the modification times of | ||
|
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.
Please add unit tests for this method.
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.
Add UT in SparkHadoopUtilSuite.scala