You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/11/18 09:19:10 UTC
[GitHub] [spark] wangyum commented on a change in pull request #29642: [SPARK-32792][SQL] Improve in filter pushdown for ParquetFilters
wangyum commented on a change in pull request #29642:
URL: https://github.com/apache/spark/pull/29642#discussion_r525929388
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFilters.scala
##########
@@ -597,12 +599,26 @@ class ParquetFilters(
createFilterHelper(pred, canPartialPushDownConjuncts = false)
.map(FilterApi.not)
- case sources.In(name, values) if canMakeFilterOn(name, values.head)
- && values.distinct.length <= pushDownInFilterThreshold =>
- values.distinct.flatMap { v =>
- makeEq.lift(nameToParquetField(name).fieldType)
- .map(_(nameToParquetField(name).fieldNames, v))
- }.reduceLeftOption(FilterApi.or)
+ case sources.In(name, values) if pushDownInFilterThreshold > 0 &&
+ values.nonEmpty && canMakeFilterOn(name, values.head) =>
+ if (values.length <= pushDownInFilterThreshold) {
+ values.flatMap { v =>
+ makeEq.lift(nameToParquetField(name).fieldType)
+ .map(_(nameToParquetField(name).fieldNames, v))
+ }.reduceLeftOption(FilterApi.or)
+ } else {
+ sparkSchema.find { f =>
+ if (caseSensitive) f.name.equals(name) else f.name.equalsIgnoreCase(name)
+ }.map(_.dataType) match {
+ case Some(dataType) =>
+ val sortedValues = values.sorted(TypeUtils.getInterpretedOrdering(dataType))
+ createFilterHelper(
+ sources.And(sources.GreaterThanOrEqual(name, sortedValues.head),
+ sources.LessThanOrEqual(name, sortedValues.last)),
+ canPartialPushDownConjuncts)
Review comment:
The logic is same to HiveShim.scala#L746-L750.
https://github.com/apache/spark/blob/09bb9bedcd27e08b86d63a6aed90d42ca4c606be/sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala#L746-L750
@cloud-fan @dongjoon-hyun @HyukjinKwon It can be improved by 6.6X in `InSet -> InFilters (values count: 100, distribution: 10)`:
```
Parquet Vectorized (Pushdown) 9520 9560 27 1.7 605.3 1.0X
Parquet Vectorized (Pushdown) 873 885 11 18.0 55.5 6.6X
```
----------------------------------------------------------------
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org