-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32792][SQL] Improve Parquet In filter pushdown #29642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
648e8e5
e5e2fe2
c5ab656
0169114
b29eca1
ebb13cc
b8cb1f4
8423c6a
5c3c8ea
af9d7d6
d67b103
869e37f
a98b354
2310a69
48250ca
11c479f
f269f8d
f0bfb06
00ff10f
27a2bf6
2545c1e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,15 +33,17 @@ import org.apache.parquet.schema.OriginalType._ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName._ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.spark.sql.catalyst.util.{CaseInsensitiveMap, DateTimeUtils} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.spark.sql.catalyst.util.{CaseInsensitiveMap, DateTimeUtils, TypeUtils} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.spark.sql.sources | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.spark.sql.types.StructType | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.spark.unsafe.types.UTF8String | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| * Some utility function to convert Spark data source filters to Parquet filters. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| class ParquetFilters( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| schema: MessageType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sparkSchema: StructType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parquetSchema: MessageType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pushDownDate: Boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pushDownTimestamp: Boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pushDownDecimal: Boolean, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -75,7 +77,7 @@ class ParquetFilters( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val primitiveFields = getPrimitiveFields(schema.getFields.asScala.toSeq).map { field => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| val primitiveFields = getPrimitiveFields(parquetSchema.getFields.asScala.toSeq).map { field => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import org.apache.spark.sql.connector.catalog.CatalogV2Implicits.MultipartIdentifierHelper | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (field.fieldNames.toSeq.quoted, field) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -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 => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
wangyum marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| values.distinct.flatMap { v => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
wangyum marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| makeEq.lift(nameToParquetField(name).fieldType) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .map(_(nameToParquetField(name).fieldNames, v)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }.reduceLeftOption(FilterApi.or) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case sources.In(name, values) if pushDownInFilterThreshold > 0 && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws | |
| Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz | |
| InSet -> InFilters (values count: 50, distribution: 50): Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative | |
| ------------------------------------------------------------------------------------------------------------------------ | |
| Parquet Vectorized 9281 9298 12 1.7 590.1 1.0X | |
| Parquet Vectorized (Pushdown) 9546 9561 17 1.6 606.9 1.0X | |
| Native ORC Vectorized 6877 6897 18 2.3 437.2 1.3X | |
| Native ORC Vectorized (Pushdown) 661 668 15 23.8 42.0 14.0X | |
| OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws | |
| Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz | |
| InSet -> InFilters (values count: 50, distribution: 90): Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative | |
| ------------------------------------------------------------------------------------------------------------------------ | |
| Parquet Vectorized 9322 9335 22 1.7 592.7 1.0X | |
| Parquet Vectorized (Pushdown) 9551 9573 18 1.6 607.2 1.0X | |
| Native ORC Vectorized 6902 6915 13 2.3 438.8 1.4X | |
| Native ORC Vectorized (Pushdown) 659 680 25 23.9 41.9 14.1X | |
| OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws | |
| Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz | |
| InSet -> InFilters (values count: 100, distribution: 10): Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative | |
| ------------------------------------------------------------------------------------------------------------------------ | |
| Parquet Vectorized 9278 9294 18 1.7 589.9 1.0X | |
| Parquet Vectorized (Pushdown) 9520 9560 27 1.7 605.3 1.0X | |
| Native ORC Vectorized 6855 6870 16 2.3 435.9 1.4X | |
| Native ORC Vectorized (Pushdown) 795 808 16 19.8 50.5 11.7X | |
| OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws | |
| Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz | |
| InSet -> InFilters (values count: 100, distribution: 50): Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative | |
| ------------------------------------------------------------------------------------------------------------------------ | |
| Parquet Vectorized 9306 9311 4 1.7 591.6 1.0X | |
| Parquet Vectorized (Pushdown) 9529 9551 16 1.7 605.8 1.0X | |
| Native ORC Vectorized 6875 6882 7 2.3 437.1 1.4X | |
| Native ORC Vectorized (Pushdown) 853 865 15 18.4 54.2 10.9X | |
| OpenJDK 64-Bit Server VM 1.8.0_232-8u232-b09-0ubuntu1~18.04.1-b09 on Linux 4.15.0-1044-aws | |
| Intel(R) Xeon(R) CPU E5-2670 v2 @ 2.50GHz | |
| InSet -> InFilters (values count: 100, distribution: 90): Best Time(ms) Avg Time(ms) Stdev(ms) Rate(M/s) Per Row(ns) Relative | |
| ------------------------------------------------------------------------------------------------------------------------ | |
| Parquet Vectorized 9256 9271 9 1.7 588.5 1.0X | |
| Parquet Vectorized (Pushdown) 9500 9520 13 1.7 604.0 1.0X | |
| Native ORC Vectorized 6843 6857 9 2.3 435.1 1.4X | |
| Native ORC Vectorized (Pushdown) 858 870 14 18.3 54.6 10.8X |
CSV:
#29642 (comment)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the default value
10is small here. What is the default threshold in IMPLA?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impala only optimize it to
>= minimum valueand<= maximum value: apache/impala@aa05c64