Github user liancheng commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7238#discussion_r35408335
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala ---
    @@ -345,6 +348,28 @@ private[sql] class ParquetRelation2(
         // Schema of the whole table, including partition columns.
         var schema: StructType = _
     
    +    def filterDataStatusesWithoutSummaries(
    +      leaves: Seq[FileStatus],
    +      dataStatuses: Seq[FileStatus]): Seq[FileStatus] = {
    +
    +      // Get the partitions that have summary files
    +      val typeInference = 
sqlContext.conf.partitionColumnTypeInferenceEnabled()
    +      val summariesPaths = metadataStatuses.map(_.getPath.getParent()) ++
    +        commonMetadataStatuses.map(_.getPath.getParent())
    +      val summariesPartitions = 
PartitioningUtils.parsePartitions(summariesPaths,
    +        PartitioningUtils.DEFAULT_PARTITION_NAME, 
typeInference).partitions.toSet
    +
    +      dataStatuses.filterNot { d =>
    +        val part = 
PartitioningUtils.parsePartitions(Seq(d.getPath.getParent()),
    +          PartitioningUtils.DEFAULT_PARTITION_NAME, typeInference)
    +        if (summariesPartitions.size > 0 && part.partitions.length > 0) {
    +          summariesPartitions.contains(part.partitions(0))
    +        } else {
    +          false
    +        }
    +      }
    +    }
    --- End diff --
    
    Just realized that I forgot one common case:
    
    ```scala
    val df = sqlContext.range(2).select('id as 'a, 'id as 'b)
    df.write.mode("overwrite").partitionBy("b").parquet("file:///tmp/foo")
    ```
    
    The above snippet creates a directory layout like this:
    
    ```
    .
    ├── _SUCCESS
    ├── _common_metadata
    ├── _metadata
    ├── b=0
    │   └── 
part-r-00003-24252842-e4e7-41e6-b1ba-bbefbd2a4a35.gz.parquet
    └── b=1
        └── part-r-00007-24252842-e4e7-41e6-b1ba-bbefbd2a4a35.gz.parquet
    ```
    
    This is because a single job only writes a single pair of summary files 
under the base directory. In this case, both partition directories are 
considered to be data files without summary files, and their footers will be 
scanned. However, compared to higher possibility of getting wrong query 
results, I still tend to accept this situation.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to