sarutak commented on a change in pull request #32074:
URL: https://github.com/apache/spark/pull/32074#discussion_r611467675
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/command/resources.scala
##########
@@ -67,17 +65,16 @@ case class ListFilesCommand(files: Seq[String] =
Seq.empty[String]) extends Runn
}
override def run(sparkSession: SparkSession): Seq[Row] = {
val fileList = sparkSession.sparkContext.listFiles()
- if (files.size > 0) {
- files.map { f =>
- val uri = new URI(f)
- val schemeCorrectedPath = uri.getScheme match {
- case null | "local" => new File(f).getCanonicalFile.toURI.toString
- case _ => f
- }
- new Path(schemeCorrectedPath).toUri.toString
Review comment:
Actually, we can get a wrong result with `new
Path(schemeCorrectedPath).toUri.toString`.
The constructor of `Path` which takes a `String` parameter doesn't handle
URI formed string properly.
For example, "file:///test%20file.txt" is already encoded and valid URI but
the constructor handles such URI as **NOT** encoded.
As a result, `new Path("file:///path/to/test%20file.txt").toUri.toString`
returns `file:///path/to/test%2020file.txt` though
`file:///path/to/test%20file.txt` is expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]