-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-36647][SQL][TESTS] Push down Aggregate (Min/Max/Count) for Parquet if filter is on partition col #34248
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 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -129,10 +129,9 @@ abstract class ParquetAggregatePushDownSuite | |
| .write.partitionBy("p").parquet(dir.getCanonicalPath) | ||
| withTempView("tmp") { | ||
| spark.read.parquet(dir.getCanonicalPath).createOrReplaceTempView("tmp"); | ||
| val enableVectorizedReader = Seq("false", "true") | ||
| for (testVectorizedReader <- enableVectorizedReader) { | ||
| Seq("false", "true").foreach { enableVectorizedReader => | ||
| withSQLConf(SQLConf.PARQUET_AGGREGATE_PUSHDOWN_ENABLED.key -> "true", | ||
| vectorizedReaderEnabledKey -> testVectorizedReader) { | ||
| vectorizedReaderEnabledKey -> enableVectorizedReader) { | ||
| val count = sql("SELECT COUNT(p) FROM tmp") | ||
| count.queryExecution.optimizedPlan.collect { | ||
| case _: DataSourceV2ScanRelation => | ||
|
|
@@ -221,7 +220,7 @@ abstract class ParquetAggregatePushDownSuite | |
| } | ||
| } | ||
|
|
||
| test("aggregate push down - query with filter not push down") { | ||
| test("aggregate push down - aggregate with data filter cannot be pushed down") { | ||
| val data = Seq((-2, "abc", 2), (3, "def", 4), (6, "ghi", 2), (0, null, 19), | ||
| (9, "mno", 7), (2, null, 7)) | ||
| withParquetTable(data, "t") { | ||
|
|
@@ -240,6 +239,29 @@ abstract class ParquetAggregatePushDownSuite | |
| } | ||
| } | ||
|
|
||
| test("aggregate push down - aggregate with partition filter can be pushed down") { | ||
| withTempPath { dir => | ||
| spark.range(10).selectExpr("id", "id % 3 as p") | ||
| .write.partitionBy("p").parquet(dir.getCanonicalPath) | ||
| withTempView("tmp") { | ||
| spark.read.parquet(dir.getCanonicalPath).createOrReplaceTempView("tmp"); | ||
| Seq("false", "true").foreach { enableVectorizedReader => | ||
| withSQLConf(SQLConf.PARQUET_AGGREGATE_PUSHDOWN_ENABLED.key -> "true", | ||
| vectorizedReaderEnabledKey -> enableVectorizedReader) { | ||
| val max = sql("SELECT max(id) FROM tmp WHERE p = 0") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add other two supported aggregate functions? And how about group by on partition column case?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added. |
||
| max.queryExecution.optimizedPlan.collect { | ||
| case _: DataSourceV2ScanRelation => | ||
| val expected_plan_fragment = | ||
| "PushedAggregation: [MAX(id)]" | ||
| checkKeywordsExistsInExplain(max, expected_plan_fragment) | ||
| } | ||
| checkAnswer(max, Seq(Row(9))) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| test("aggregate push down - push down only if all the aggregates can be pushed down") { | ||
| val data = Seq((-2, "abc", 2), (3, "def", 4), (6, "ghi", 2), (0, null, 19), | ||
| (9, "mno", 7), (2, null, 7)) | ||
|
|
@@ -356,10 +378,9 @@ abstract class ParquetAggregatePushDownSuite | |
| spark.createDataFrame(rdd, schema).write.parquet(file.getCanonicalPath) | ||
| withTempView("test") { | ||
| spark.read.parquet(file.getCanonicalPath).createOrReplaceTempView("test") | ||
| val enableVectorizedReader = Seq("false", "true") | ||
| for (testVectorizedReader <- enableVectorizedReader) { | ||
| Seq("false", "true").foreach { enableVectorizedReader => | ||
| withSQLConf(SQLConf.PARQUET_AGGREGATE_PUSHDOWN_ENABLED.key -> "true", | ||
| vectorizedReaderEnabledKey -> testVectorizedReader) { | ||
| vectorizedReaderEnabledKey -> enableVectorizedReader) { | ||
|
|
||
| val testMinWithTS = sql("SELECT min(StringCol), min(BooleanCol), min(ByteCol), " + | ||
| "min(BinaryCol), min(ShortCol), min(IntegerCol), min(LongCol), min(FloatCol), " + | ||
|
|
@@ -477,10 +498,9 @@ abstract class ParquetAggregatePushDownSuite | |
| } | ||
|
|
||
| test("aggregate push down - column name case sensitivity") { | ||
| val enableVectorizedReader = Seq("false", "true") | ||
| for (testVectorizedReader <- enableVectorizedReader) { | ||
| Seq("false", "true").foreach { enableVectorizedReader => | ||
| withSQLConf(SQLConf.PARQUET_AGGREGATE_PUSHDOWN_ENABLED.key -> "true", | ||
| vectorizedReaderEnabledKey -> testVectorizedReader) { | ||
| vectorizedReaderEnabledKey -> enableVectorizedReader) { | ||
| withTempPath { dir => | ||
| spark.range(10).selectExpr("id", "id % 3 as p") | ||
| .write.partitionBy("p").parquet(dir.getCanonicalPath) | ||
|
|
||
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.
So group by on partition column is not supported yet. Then this comment is not correct.