wangyum opened a new pull request #29642:
URL: https://github.com/apache/spark/pull/29642
### What changes were proposed in this pull request?
Improve in filter pushdown for ParquetFilters:
- Remove `distinct` operation because it is expensive and duplicate values
should be removed by `OptimizeIn`
```scala
import org.apache.spark.benchmark.Benchmark
val N = 5000000
val array = Range(1, N).toArray
val benchmark = new Benchmark(s"Benchmark distinct", valuesPerIteration =
N, minNumIters = 30)
benchmark.addCase("array.length") { _ =>
array.length
}
benchmark.addCase("array.distinct.length") { _ =>
array.distinct.length
}
benchmark.run()
```
```
Java HotSpot(TM) 64-Bit Server VM 1.8.0_251-b08 on Mac OS X 10.15.6
Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Benchmark distinct: Best Time(ms) Avg Time(ms)
Stdev(ms) Rate(M/s) Per Row(ns) Relative
------------------------------------------------------------------------------------------------------------------------
array.length 0 0
0 48076923.1 0.0 1.0X
array.distinct.length 711 1389
498 7.0 142.2 0.0X
```
- Add an empty check because `values` may be empty.
### Why are the changes needed?
Enhance code robustness.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Unit test.
----------------------------------------------------------------
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]