[
https://issues.apache.org/jira/browse/CALCITE-3895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Feng Zhu resolved CALCITE-3895.
-------------------------------
Resolution: Not A Problem
> 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)