cloud-fan commented on a change in pull request #29642:
URL: https://github.com/apache/spark/pull/29642#discussion_r526092610
##########
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:
ah, then can we turn it into a util method and use it in all the filter
pushdown place?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]