You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/04/06 17:01:00 UTC

[jira] [Commented] (CALCITE-3895) When the group sets of Aggregate is not null, union of its members should contain group key

    [ https://issues.apache.org/jira/browse/CALCITE-3895?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17076470#comment-17076470 ] 

Julian Hyde commented on CALCITE-3895:
--------------------------------------

I agree. And equivalently, every element of {{groupSets}} should contain {{groupSet}}. I would make it an 'if ... throw' rather than an assert.

A separate question. Should we require that {{union(groupSets)}} equals {{groupSet}}? This assumption is behind CALCITE-3893.

 

> When the group sets of Aggregate is not null, union of its members should contain group key
> -------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3895
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3895
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.22.0
>            Reporter: Feng Zhu
>            Assignee: Feng Zhu
>            Priority: Major
>             Fix For: 1.23.0
>
>
> In general,  the following query will fail in validation phase with “deptno is not being grouped”.
> {code:java}
> select deptno, count(*) as c
> from emp 
> group by grouping sets (())
> {code}
> However, there is no constraint in Aggregate. For example, we can still create the RelNode by RelBuilder.
> {code:java}
> @Test void testAggregate6() {
>   // Equivalent SQL (illegal):
>   //   SELECT deptno, count(*) AS C
>   //   FROM emp
>   //   GROUP BY grouping sets (())
>   final RelBuilder builder = RelBuilder.create(config().build());
>   RelNode aggregate = builder.scan("EMP")
>         .aggregate(
>             builder.groupKey(ImmutableBitSet.of(0),
>             (Iterable<ImmutableBitSet>) ImmutableList.of(
>                 ImmutableBitSet.of())),
>             builder.countStar("C"))
>         .build();
>   });
> }
> {code}
> It is interesting that the rutime can process illegal RelNode and return result as expected.
> This issue is exposed in CALCITE-3893. However, we can also find the same case in _*RelMetadataTest#checkAverageRowSize*_. So I opened an individual Jira to discuss it.
> I propose to add the constraint below: assert
> {code:java}
> ImmutableBitSet.union(groupSets).contains(groupSet)
> : "the union of group sets should contain group key";
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)