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

    https://github.com/apache/spark/pull/14649#discussion_r74872775
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFileFormat.scala
 ---
    @@ -423,6 +425,54 @@ class ParquetFileFormat
           sqlContext.sessionState.newHadoopConf(),
           options)
       }
    +
    +  override def filterPartitions(
    +      filters: Seq[Filter],
    +      schema: StructType,
    +      conf: Configuration,
    +      allFiles: Seq[FileStatus],
    +      root: Path,
    +      partitions: Seq[Partition]): Seq[Partition] = {
    +    // Read the "_metadata" file if available, contains all block headers. 
On S3 better to grab
    +    // all of the footers in a batch rather than having to read every 
single file just to get its
    +    // footer.
    +    allFiles.find(_.getPath.getName == 
ParquetFileWriter.PARQUET_METADATA_FILE).map { stat =>
    +      val metadata = ParquetFileReader.readFooter(conf, stat, 
ParquetMetadataConverter.NO_FILTER)
    +      partitions.map { part =>
    +        filterByMetadata(
    +          filters,
    +          schema,
    +          conf,
    +          root,
    +          metadata,
    +          part)
    +      }.filterNot(_.files.isEmpty)
    +    }.getOrElse(partitions)
    +  }
    +
    +  private def filterByMetadata(
    +      filters: Seq[Filter],
    +      schema: StructType,
    +      conf: Configuration,
    +      root: Path,
    +      metadata: ParquetMetadata,
    +      partition: Partition): Partition = {
    +    val blockMetadatas = metadata.getBlocks.asScala
    +    val parquetSchema = metadata.getFileMetaData.getSchema
    +    val conjunctiveFilter = filters
    +      .flatMap(ParquetFilters.createFilter(schema, _))
    +      .reduceOption(FilterApi.and)
    +    conjunctiveFilter.map { conjunction =>
    +      val filteredBlocks = RowGroupFilter.filterRowGroups(
    --- End diff --
    
    Do you mind if I ask a question please?
    
    So, if my understanding is correct, Parquet filters rowgroups in both 
normal reader and vectorized reader already 
(https://github.com/apache/spark/pull/13701). Is this doing the same thing in 
Spark-side?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to