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

    https://github.com/apache/spark/pull/7238#discussion_r35407595
  
    --- 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 --
    
    Seems that this function can be simplified to:
    
    ```scala
        private def findDataStatusesWithoutSummaries(
            summaries: Seq[FileStatus], dataStatuses: Seq[FileStatus]): 
Seq[FileStatus] = {
          val directoriesWithSummaries = 
summaries.map(_.getPath.getParent).toSet
          dataStatuses.filterNot(f => 
directoriesWithSummaries.contains(f.getPath.getParent))
        }
    ```


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