-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-31663][SQL] Grouping sets with having clause returns the wrong result #28501
Conversation
Test build #122510 has finished for PR 28501 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
Test build #122547 has finished for PR 28501 at commit
|
Test build #122548 has finished for PR 28501 at commit
|
Test build #122551 has finished for PR 28501 at commit
|
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
Outdated
Show resolved
Hide resolved
Test build #122572 has finished for PR 28501 at commit
|
retest this please |
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
Test build #122580 has finished for PR 28501 at commit
|
Test build #122610 has finished for PR 28501 at commit
|
retest this please |
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/unresolved.scala
Outdated
Show resolved
Hide resolved
case _ => | ||
Filter(predicate, plan) | ||
} | ||
UnresolvedHaving(predicate, plan) |
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.
does global aggregate still work? e.g. UnresolvedHaving(Project(agg_func ...))
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.
Yes, it still works, the UnresolvedHaving
will be changed to Filter in rule ResolveAggregateFunction
.
Test build #122615 has finished for PR 28501 at commit
|
Test build #122611 has finished for PR 28501 at commit
|
I'm planning to cut RC2 tomorrow for 2.4.6, looking at the state of this PR I'm assuming it won't make it for 2.4.6 and we can put it in 2.4.7. Does that sound ok to folks? |
@holdenk Thanks for notifying, I'll address all the comments today. Yep, if it can be merged before cutting 2.4.6, let's put it in 2.4.7. |
It's a long-standing bug, so it doesn't block 2.4.6. I'll see if I can merge it today. |
Test build #122648 has finished for PR 28501 at commit
|
retest this please |
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
Outdated
Show resolved
Hide resolved
Test build #5038 has started for PR 28501 at commit |
Test build #122657 has finished for PR 28501 at commit
|
retest this please |
Test build #122678 has finished for PR 28501 at commit
|
Test build #122679 has finished for PR 28501 at commit
|
thanks, merging to master/3.0/2.4! |
Thank you so much, @xuanyuanking and @cloud-fan . |
… result - Resolve the havingcondition with expanding the GROUPING SETS/CUBE/ROLLUP expressions together in `ResolveGroupingAnalytics`: - Change the operations resolving directions to top-down. - Try resolving the condition of the filter as though it is in the aggregate clause by reusing the function in `ResolveAggregateFunctions` - Push the aggregate expressions into the aggregate which contains the expanded operations. - Use UnresolvedHaving for all having clause. Correctness bug fix. See the demo and analysis in SPARK-31663. Yes, correctness bug fix for HAVING with GROUPING SETS. New UTs added. Closes apache#28501 from xuanyuanking/SPARK-31663. Authored-by: Yuanjian Li <xyliyuanjian@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 86bd37f) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
Hi, @cloud-fan . This seems to be not in
|
… result - Resolve the havingcondition with expanding the GROUPING SETS/CUBE/ROLLUP expressions together in `ResolveGroupingAnalytics`: - Change the operations resolving directions to top-down. - Try resolving the condition of the filter as though it is in the aggregate clause by reusing the function in `ResolveAggregateFunctions` - Push the aggregate expressions into the aggregate which contains the expanded operations. - Use UnresolvedHaving for all having clause. Correctness bug fix. See the demo and analysis in SPARK-31663. Yes, correctness bug fix for HAVING with GROUPING SETS. New UTs added. Closes #28501 from xuanyuanking/SPARK-31663. Authored-by: Yuanjian Li <xyliyuanjian@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit 86bd37f) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
done. It has some conflicts, so I fixed them and ran tests locally, which takes some time. |
What changes were proposed in this pull request?
ResolveGroupingAnalytics
:ResolveAggregateFunctions
Why are the changes needed?
Correctness bug fix. See the demo and analysis in SPARK-31663.
Does this PR introduce any user-facing change?
Yes, correctness bug fix for HAVING with GROUPING SETS.
How was this patch tested?
New UTs added.