[
https://issues.apache.org/jira/browse/CALCITE-2051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16257761#comment-16257761
]
Jesus Camacho Rodriguez commented on CALCITE-2051:
--------------------------------------------------
bq. I do not believe so. In Hive, given "GROUP BY c1, c2, ... GROUPING SETS
((c11, c12, ), (c21, c22, ...), ...)", AFAICT, you can always remove the "c1,
c2, ..." with no change in semantics.
Removing the group by clause and preserving semantics would imply a rewriting
as the one described in my comment above, there is a change in Semantics. In
addition, the columns in each grouping set need to be a subset of the columns
in the group by set. For instance, GROUP BY c1, c2, c3 GROUPING SETS ((c1),
(c3)) is valid too.
The restriction is enforceable, you can rewrite the expression into an
equivalent one, but it is not as simple as writing a union of the grouping sets
when we go into Calcite. In addition, we would need to rewrite, i.e., apply an
additional function, functions such as groupingId to return the expected value.
> Rules using Aggregate might check for simple grouping sets incorrectly
> ----------------------------------------------------------------------
>
> Key: CALCITE-2051
> URL: https://issues.apache.org/jira/browse/CALCITE-2051
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Jesus Camacho Rodriguez
> Assignee: Jesus Camacho Rodriguez
> Priority: Critical
> Fix For: 1.15.0
>
>
> CALCITE-1069 removed the indicator columns for Aggregate operators. In some
> places, the indicator boolean check was replaced by the following check:
> {{aggregate.getGroupSets().size() > 1}}. However, that check is incomplete,
> it should have been replaced by {{aggregate.getGroupType() != Group.SIMPLE}}.
> For instance :
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/rules/AggregateProjectMergeRule.java#L91
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)