You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "databricks-david-lewis (via GitHub)" <gi...@apache.org> on 2023/04/26 06:15:50 UTC

[GitHub] [spark] databricks-david-lewis commented on a diff in pull request #40947: [Spark-43284] Switch back to url-encoded strings

databricks-david-lewis commented on code in PR #40947:
URL: https://github.com/apache/spark/pull/40947#discussion_r1177391819


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileFormat.scala:
##########
@@ -265,8 +265,8 @@ object FileFormat {
    * fields of the [[PartitionedFile]], and do have entries in the file's metadata map.
    */
   val BASE_METADATA_EXTRACTORS: Map[String, PartitionedFile => Any] = Map(
-    FILE_PATH -> { pf: PartitionedFile => pf.toPath.toString },
-    FILE_NAME -> { pf: PartitionedFile => pf.toPath.getName },
+    FILE_PATH -> { pf: PartitionedFile => pf.filePath.urlEncoded },
+    FILE_NAME -> { pf: PartitionedFile => new Path(pf.filePath.urlEncoded).getName },

Review Comment:
   Just using `Path.getName` returns the unencoded string (i.e. `some file.txt`).
   
   The new way will return the encoded path name: `some%20file.txt`.
   
   It's not exactly right with URI parameters though... I just updated it to
   `new Path(pf.filePath.toUri.getRawPath).getName`



-- 
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.

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org