-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-17310][SQL] Add an option to disable record-level filter in Parquet-side #15049
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,8 +45,29 @@ import org.apache.spark.util.{AccumulatorContext, AccumulatorV2} | |
| * | ||
| * 2. `Tuple1(Option(x))` is used together with `AnyVal` types like `Int` to ensure the inferred | ||
| * data type is nullable. | ||
| * | ||
| * NOTE: | ||
| * | ||
| * This file intendedly enables record-level filtering explicitly. If new test cases are | ||
| * dependent on this configuration, don't forget you better explicitly set this configuration | ||
| * within the test. | ||
| */ | ||
| class ParquetFilterSuite extends QueryTest with ParquetTest with SharedSQLContext { | ||
|
|
||
| override def beforeEach(): Unit = { | ||
| super.beforeEach() | ||
| // Note that there are many tests here that require record-level filtering set to be true. | ||
| spark.conf.set(SQLConf.PARQUET_RECORD_FILTER_ENABLED.key, "true") | ||
| } | ||
|
|
||
| override def afterEach(): Unit = { | ||
| try { | ||
| spark.conf.unset(SQLConf.PARQUET_RECORD_FILTER_ENABLED.key) | ||
| } finally { | ||
| super.afterEach() | ||
| } | ||
| } | ||
|
|
||
| private def checkFilterPredicate( | ||
| df: DataFrame, | ||
| predicate: Predicate, | ||
|
|
@@ -369,7 +390,7 @@ class ParquetFilterSuite extends QueryTest with ParquetTest with SharedSQLContex | |
|
|
||
| test("Filter applied on merged Parquet schema with new column should work") { | ||
| import testImplicits._ | ||
| Seq("true", "false").map { vectorized => | ||
| Seq("true", "false").foreach { vectorized => | ||
| withSQLConf(SQLConf.PARQUET_FILTER_PUSHDOWN_ENABLED.key -> "true", | ||
| SQLConf.PARQUET_SCHEMA_MERGING_ENABLED.key -> "true", | ||
| SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> vectorized) { | ||
|
|
@@ -491,7 +512,7 @@ class ParquetFilterSuite extends QueryTest with ParquetTest with SharedSQLContex | |
| } | ||
| } | ||
|
|
||
| test("Fiters should be pushed down for vectorized Parquet reader at row group level") { | ||
| test("Filters should be pushed down for vectorized Parquet reader at row group level") { | ||
| import testImplicits._ | ||
|
|
||
| withSQLConf(SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "true", | ||
|
|
@@ -555,6 +576,32 @@ class ParquetFilterSuite extends QueryTest with ParquetTest with SharedSQLContex | |
| } | ||
| } | ||
| } | ||
|
|
||
| test("Filters should be pushed down for Parquet readers at row group level") { | ||
|
||
| import testImplicits._ | ||
|
|
||
| withSQLConf( | ||
| // Makes sure disabling 'spark.sql.parquet.recordFilter' still enables | ||
| // row group level filtering. | ||
| SQLConf.PARQUET_RECORD_FILTER_ENABLED.key -> "false", | ||
| SQLConf.PARQUET_FILTER_PUSHDOWN_ENABLED.key -> "true", | ||
| SQLConf.PARQUET_VECTORIZED_READER_ENABLED.key -> "false") { | ||
| withTempPath { path => | ||
| val data = (1 to 1024) | ||
| data.toDF("a").coalesce(1) | ||
| .write.option("parquet.block.size", 512) | ||
| .parquet(path.getAbsolutePath) | ||
| val df = spark.read.parquet(path.getAbsolutePath).filter("a == 500") | ||
| // Here, we strip the Spark side filter and check the actual results from Parquet. | ||
| val actual = stripSparkFilter(df).collect().length | ||
| // Since those are filtered at row group level, the result count should be less | ||
| // than the total length but should not be a single record. | ||
| // Note that, if record level filtering is enabled, it should be a single record. | ||
| // If no filter is pushed down to Parquet, it should be the total length of data. | ||
| assert(actual > 1 && actual < data.length) | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| class NumRowGroupsAcc extends AccumulatorV2[Integer, Integer] { | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will this also disables parquet native row group filtering?
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.
Nope, I am sure it still enables group filtering. I will double check this and be back within few days.
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.
@jiangxb1987 If you do not like the solution here, could you submit the one you propose?
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.
Hm, I am active here. Could you share what's the problem here in this solution you'd imagine and discuss first?
I think there's no point of disabling row group filtering and, @jiangxb1987 asked if it actually disables row group filtering too, which might downgrade the performance. Current change does not do this.
I added a test for this concern - #15049 (comment).
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.
If we want to disable both, I think we can simply disable Parquet predicate pushdown BTW.
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.
It should be fine to make this change, I was thinking we could make this change by setting the value of
ParquetInputFormat.RECORD_FILTERING_ENABLEDto false. Both way works and I don't have strong preference. Sorry for the late response.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.
Oh, I have been looking at the JIRA as well but I thought that only exists in 1.9.0 as specified in the JIRA, also given #14671 (comment). Looks that flag also exists in Parquet 1.8.2 as well.
Yup, I don't have strong preference too.