cloud-fan commented on code in PR #40947:
URL: https://github.com/apache/spark/pull/40947#discussion_r1184672520
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/FileFormat.scala:
##########
@@ -265,8 +265,10 @@ 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 },
Review Comment:
I tried this
```
scala> sql("create table p1 using parquet location 'file:/tmp/path'")
res2: org.apache.spark.sql.DataFrame = []
scala> sql("create table p2 using parquet location 'file:///tmp/path'")
res3: org.apache.spark.sql.DataFrame = []
scala> sql("select _metadata.file_path from p1").show
+--------------------+
| file_path|
+--------------------+
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
+--------------------+
scala> sql("select _metadata.file_path from p2").show
+--------------------+
| file_path|
+--------------------+
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
|file:/tmp/path/pa...|
+--------------------+
```
To avoid regression I think we should do normalization here as well.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]