You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/08/11 16:19:47 UTC
[GitHub] [spark] IonutBoicuAms opened a new pull request #33711: Fix bug in disable unnecessary bucketed scan
IonutBoicuAms opened a new pull request #33711:
URL: https://github.com/apache/spark/pull/33711
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
8. If you want to add or modify an error type or message, please read the guideline first in
'core/src/main/resources/error/README.md'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
Fix bug in `DisableUnnecessaryBucketedScan`.
Aggregate functions over no grouping keys on tables with a single bucket return multiple rows.
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
Bug fixing. Aggregates over no grouping keys should return a single row.
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
No.
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
Added new test in `DisableUnnecessaryBucketedScanSuite`.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
c21 commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687195422
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
Actually after a second thought, I think the change here should work. For the query like https://github.com/apache/spark/pull/33711#discussion_r687173621, the query plan when entering this rule, would be:
```
HashAggregate(keys=[], functions=[sum(id#41)], output=[sum(id)#45L])
+- Exchange SinglePartition, ENSURE_REQUIREMENTS, [id=#66]
+- HashAggregate(keys=[], functions=[partial_sum(id#41)], output=[sum#48L])
+- FileScan
```
So the bucket scan will be automatically disabled by the rule, because there's a shuffle between `HashAggregate` and `FileScan`.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 commented on a change in pull request #33711: [SPARK-36489][SQL] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
c21 commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r688028096
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
@ulysses-you - this is a bug in `DisableUnnecessaryBucketedScan` itself. In addition:
> Is it better that change the outpt partitioning in FileSourceScanExec to UnknownPartitioning if the bucket is 1 ?
This will cause regression for some queries, e.g. the aggregation query in https://github.com/apache/spark/pull/33711#discussion_r687173621. An extra shuffle is needed before aggregation, if the output partitioning is changed from `HashPartitioning(id, 1)` to `UnknownPartitioning`.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897368109
Can you file a JIRA please
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-896966671
Can one of the admins verify this patch?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
c21 commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897091347
cc @gengliangwang and @cloud-fan FYI. I think this might be a blocker for release.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan closed pull request #33711: [SPARK-36489][SQL] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #33711:
URL: https://github.com/apache/spark/pull/33711
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897286394
**[Test build #142350 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142350/testReport)** for PR 33711 at commit [`266a5f1`](https://github.com/apache/spark/commit/266a5f1bedb640b0adfc2a07a0f0cb7d66188c5c).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] hvanhovell commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
hvanhovell commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897164046
ok to 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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] IonutBoicuAms commented on pull request #33711: [SPARK-36489] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
IonutBoicuAms commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897404102
Added JIRA ticket.
How do we make sure this fix is merged into all affected versions: 3.1.0, 3.1.1, 3.1.2, 3.2.0, 3.1.3 ?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
c21 commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897086852
I confirm this is a valid bug, thanks for flagging this @IonutBoicuAms. Could you file a JIRA as well (more info - https://spark.apache.org/contributing.html)? Thanks.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 edited a comment on pull request #33711: [SPARK-36489][SQL] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
c21 edited a comment on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897884358
@IonutBoicuAms - sorry for the inconvenience, but if you want to be unblocked in the existing Spark release versions, you can add config in your query to disable this physical plan rule (`spark.sql.sources.bucketing.autoBucketedScan.enabled`=`false`). With setting this config, the query will have correct result. Thanks.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] ulysses-you commented on a change in pull request #33711: [SPARK-36489][SQL] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r688186015
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
ah I see it, thank you @cloud-fan @c21 !
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] IonutBoicuAms commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
IonutBoicuAms commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687185726
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
If you disable bucket scan, then it will not enter the `disableBucketWithInterestingPartition` right?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #33711: [SPARK-36489] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897403452
Can one of the admins verify this patch?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
c21 commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687111865
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/sources/DisableUnnecessaryBucketedScanSuite.scala
##########
@@ -258,4 +258,30 @@ abstract class DisableUnnecessaryBucketedScanSuite
}
}
}
+
+ test("Aggregates with no groupby over tables having 1 BUCKET, return multiple rows") {
+ withTable("t1") {
+ withSQLConf(SQLConf.AUTO_BUCKETED_SCAN_ENABLED.key -> "true") {
+ spark.sql(
+ """
+ | CREATE TABLE t1 (
+ | `id` BIGINT,
+ | `event_date` DATE)
+ | USING PARQUET
+ | CLUSTERED BY (id)
+ | INTO 1 BUCKETS
+ |""".stripMargin)
+ spark.sql(
+ """
+ |INSERT INTO TABLE t1 VALUES(1.23, cast("2021-07-07" as date))
+ |""".stripMargin)
+ spark.sql(
+ """
+ |INSERT INTO TABLE t1 VALUES(2.28, cast("2021-08-08" as date))
+ |""".stripMargin)
+ val result = spark.sql("select sum(id) from t1").count()
+ assert(result == 1)
Review comment:
how about checking the result itself as well?
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/sources/DisableUnnecessaryBucketedScanSuite.scala
##########
@@ -258,4 +258,30 @@ abstract class DisableUnnecessaryBucketedScanSuite
}
}
}
+
+ test("Aggregates with no groupby over tables having 1 BUCKET, return multiple rows") {
+ withTable("t1") {
+ withSQLConf(SQLConf.AUTO_BUCKETED_SCAN_ENABLED.key -> "true") {
+ spark.sql(
+ """
+ | CREATE TABLE t1 (
Review comment:
nit: indentation seems off.
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
`AllTuples` is only interesting when the underlying file scan operator has only 1 bucket. So I think we need have a way to check the scan operator to have only 1 bucket as well.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897220043
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/46857/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897211355
Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46857/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897195254
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/46857/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687407918
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
This is a bug of the `DisableUnnecessaryBucketedScan` rule, IIUC
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 commented on pull request #33711: [SPARK-36489][SQL] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
c21 commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897884358
@IonutBoicuAms - sorry for the inconvenience, but if you want to be unblocked in the existing Spark release version (3.1.1), you can add config in your query to disable this physical plan rule (`spark.sql.sources.bucketing.autoBucketedScan.enabled`=`false`). With setting this config, the query will have correct result. Thanks.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897374324
The fix LGTM. If a table has only one bucket, it can satisfy `AllTuples` and no shuffle is needed for aggregate without group keys. However, if we disable bucket scan, then `AllTuples` is not satisfied any more and the query returns wrong result.
@IonutBoicuAms can you open a JIRA ticket and also enrich the PR description a little bit to explain why the bug happens?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897292314
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142350/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] c21 commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
c21 commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687173621
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
For a query like below
```
SELECT SUM(id)
FROM t1
```
If table `t1` has more than 1 bucket (say 4 buckets), we can still disable bucket scan, because scan will have 4 RDD partitions/tasks with bucketed scan, and it does not satisfy single partition requirement from `AllTuples`.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] IonutBoicuAms commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
IonutBoicuAms commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687165516
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
`AllTuples` require a single partition. I don't think the additional check for the number of buckets is required.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] IonutBoicuAms commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
IonutBoicuAms commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687153082
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/sources/DisableUnnecessaryBucketedScanSuite.scala
##########
@@ -258,4 +258,30 @@ abstract class DisableUnnecessaryBucketedScanSuite
}
}
}
+
+ test("Aggregates with no groupby over tables having 1 BUCKET, return multiple rows") {
+ withTable("t1") {
+ withSQLConf(SQLConf.AUTO_BUCKETED_SCAN_ENABLED.key -> "true") {
+ spark.sql(
+ """
+ | CREATE TABLE t1 (
+ | `id` BIGINT,
+ | `event_date` DATE)
+ | USING PARQUET
+ | CLUSTERED BY (id)
+ | INTO 1 BUCKETS
+ |""".stripMargin)
+ spark.sql(
+ """
+ |INSERT INTO TABLE t1 VALUES(1.23, cast("2021-07-07" as date))
+ |""".stripMargin)
+ spark.sql(
+ """
+ |INSERT INTO TABLE t1 VALUES(2.28, cast("2021-08-08" as date))
+ |""".stripMargin)
+ val result = spark.sql("select sum(id) from t1").count()
+ assert(result == 1)
Review comment:
Done
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897167001
**[Test build #142350 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142350/testReport)** for PR 33711 at commit [`266a5f1`](https://github.com/apache/spark/commit/266a5f1bedb640b0adfc2a07a0f0cb7d66188c5c).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897292314
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/142350/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897167001
**[Test build #142350 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/142350/testReport)** for PR 33711 at commit [`266a5f1`](https://github.com/apache/spark/commit/266a5f1bedb640b0adfc2a07a0f0cb7d66188c5c).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] IonutBoicuAms commented on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
IonutBoicuAms commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-896976053
@c21 original author of the files, can you review this?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-896966671
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] ulysses-you commented on a change in pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on a change in pull request #33711:
URL: https://github.com/apache/spark/pull/33711#discussion_r687307744
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/bucketing/DisableUnnecessaryBucketedScan.scala
##########
@@ -120,7 +120,7 @@ object DisableUnnecessaryBucketedScan extends Rule[SparkPlan] {
private def hasInterestingPartition(plan: SparkPlan): Boolean = {
plan.requiredChildDistribution.exists {
- case _: ClusteredDistribution | _: HashClusteredDistribution => true
+ case _: ClusteredDistribution | _: HashClusteredDistribution | AllTuples => true
Review comment:
It's flaky to fix this issue in an optimizer rule since this rule can be disabled sometime. Is it better that change the outpt partitioning in `FileSourceScanExec` to `UnknownPartitioning` if the bucket is 1 ?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #33711: [SPARK-36489][SQL] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897408843
Released versions are static and can't be changed. New releases will ship this fix, like 3.1.3 and 3.2.0
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan closed pull request #33711: Fix bug in disable unnecessary bucketed scan
Posted by GitBox <gi...@apache.org>.
cloud-fan closed pull request #33711:
URL: https://github.com/apache/spark/pull/33711
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] cloud-fan commented on pull request #33711: [SPARK-36489][SQL] Aggregate functions over no grouping keys, on tables with a single bucket, return multiple rows
Posted by GitBox <gi...@apache.org>.
cloud-fan commented on pull request #33711:
URL: https://github.com/apache/spark/pull/33711#issuecomment-897409799
thanks, merging to master/3.2/3.1!
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org