HyukjinKwon commented on a change in pull request #27031: [SPARK-30373][SQL]
Avoid unnecessary sort for ParquetUtils.splitFiles
URL: https://github.com/apache/spark/pull/27031#discussion_r361925962
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetUtils.scala
##########
@@ -112,15 +114,26 @@ object ParquetUtils {
metadata: Seq[FileStatus],
commonMetadata: Seq[FileStatus])
- private def splitFiles(allFiles: Seq[FileStatus]): FileTypes = {
- val leaves = allFiles.toArray.sortBy(_.getPath.toString)
Review comment:
Yes, that issue was specific to the ordering; however, it can cause a
behaviour change: we will pick one file to read the schema, right?
It is possible to put the complete parquet file in the top in a directory,
and other files are partial. For instance,
```scala
scala> spark.read.parquet("test/a.snappy.parquet")
res1: org.apache.spark.sql.DataFrame = [a: bigint, b: bigint]
scala> spark.read.parquet("test/b.snappy.parquet")
res2: org.apache.spark.sql.DataFrame = [b: bigint]
scala> spark.read.parquet("test").show()
+----+---+
| a| b|
+----+---+
| 0| 0|
| 1| 1|
| 2| 2|
|null| 0|
|null| 1|
|null| 2|
+----+---+
```
If the order is switched:
```scala
scala> spark.read.parquet("test").show()
+---+
| b|
+---+
| 0|
| 1|
| 2|
| 0|
| 1|
| 2|
+---+
```
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]