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

    https://github.com/apache/spark/pull/5210#discussion_r27255249
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/parquet/newParquet.scala ---
    @@ -435,11 +435,18 @@ private[sql] case class ParquetRelation2(
         // Push down filters when possible. Notice that not all filters can be 
converted to Parquet
         // filter predicate. Here we try to convert each individual predicate 
and only collect those
         // convertible ones.
    -    predicates
    -      .flatMap(ParquetFilters.createFilter)
    -      .reduceOption(FilterApi.and)
    -      .filter(_ => sqlContext.conf.parquetFilterPushDown)
    -      .foreach(ParquetInputFormat.setFilterPredicate(jobConf, _))
    +    if (sqlContext.conf.parquetFilterPushDown) {
    +      predicates
    +        // Don't push down predicates which reference partition columns
    +        .filter { pred =>
    +          val partitionColNames = partitionColumns.map(_.name).toSet
    +          val referencedColNames = pred.references.map(_.name).toSet
    +          referencedColNames.intersect(partitionColNames).isEmpty
    +        }
    +        .flatMap(ParquetFilters.createFilter)
    --- End diff --
    
    Reasons why I think our style guide should prefer `reduceOption` to 
`reduce`/`reduceLeft`:
    
     - SPARK-877
    java.lang.UnsupportedOperationException: empty.reduceLeft in UI
     - SPARK-744
    BlockManagerUI with no RDD: java.lang.UnsupportedOperationException: 
empty.reduceLeft
     - SPARK-4968
    [SparkSQL] java.lang.UnsupportedOperationException when hive partition 
doesn't exist and order by and limit are used
     - SPARK-4318
    Fix empty sum distinct.
     - SPARK-5852
    Fail to convert a newly created empty metastore parquet table to a data 
source parquet table.
     - SPARK-6245
    jsonRDD() of empty RDD results in exception


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