uros-db commented on code in PR #56891:
URL: https://github.com/apache/spark/pull/56891#discussion_r3528833549
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/GroupingAnalyticsTransformer.scala:
##########
@@ -153,19 +243,27 @@ object GroupingAnalyticsTransformer extends SQLConfHelper
with AliasHelper {
/**
* Collect the last grouping expression since the provided [[Aggregate]]
should have grouping id
* as the last grouping key.
+ *
+ * A grand-total `GROUP BY GROUPING SETS (())` is lowered to a global
[[Aggregate]] with no
+ * grouping expressions (see [[apply]]), so there is no `spark_grouping_id`
key and no grouping
+ * columns; return an empty sequence for it.
*/
def collectGroupingExpressions(aggregate: Aggregate): Seq[Expression] = {
- val gid = aggregate.groupingExpressions.last
- gid match {
- case attributeReference: AttributeReference =>
- if (attributeReference.name != VirtualColumn.groupingIdName) {
+ if (aggregate.groupingExpressions.isEmpty) {
Review Comment:
Thank you Max! Confirmed - real bug, fixed in 14544d66880. Now tag the
lowered grand total (GRAND_TOTAL_AGGREGATE_TAG) and key
collectGroupingExpressions on the tag, so a plain no-GROUP BY aggregate still
throws UNSUPPORTED_GROUPING_EXPRESSION (parity with the SELECT-list path).
Added negative golden cases.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]