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

yanjing.wang edited comment on CALCITE-4665 at 7/13/21, 7:32 AM:
-----------------------------------------------------------------

Sorry [~nobigo], I haven't reviewed it. I'm wondering how we can get 
"LogicalAggregate(group=[\{0, 1, 2}], groups=[[\{0, 1}, \{0}]], C=[COUNT()], 
S=[SUM($5)])" so that job column is always null. could it appear from 
[~julianhyde]'s comment?
{code:java}
GROUP BY GROUPING SETS(("EMPNO", "ENAME", "JOB"),("EMPNO", "ENAME"), 
"EMPNO")HAVING GROUPING_ID("EMPNO", "ENAME", "JOB") != 7
{code}
 


was (Author: yanjing.wang):
Sorry [~nobigo], I haven't reviewed it. I'm wondering how we can get 
"LogicalAggregate(group=[\\{0, 1, 2}], groups=[[\\{0, 1}, \\{0}]], C=[COUNT()], 
S=[SUM($5)])" so that job column is always null. could it appear from 
[~julianhyde]'s comment?
{code:java}
GROUP BY GROUPING SETS(("EMPNO", "ENAME", "JOB"),("EMPNO", "ENAME"), 
"EMPNO")HAVING GROUPING_ID("EMPNO", "ENAME", "JOB") != 7
{code}
 

> When group key is a superset of the union of the groupKeys will generate the 
> wrong Sql
> --------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4665
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4665
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.22.0
>            Reporter: xiejiajun
>            Assignee: duan xiong
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.28.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> The UT:
> {code:java}
> private RelBuilder example5(RelBuilder builder) {
>   return builder
>       .scan("EMP")
>       .aggregate(builder.groupKey(ImmutableBitSet.of(0, 1 ,2),
>           (Iterable<ImmutableBitSet>)
>               
> ImmutableList.of(ImmutableBitSet.of(0,1),ImmutableBitSet.of(0))),
>           builder.count(false, "C"),
>           builder.sum(false, "S", builder.field("SAL"))).filter(
>           builder.call(SqlStdOperatorTable.GREATER_THAN, builder.field("C"),
>               builder.literal(10)))
>       
> .filter(builder.call(SqlStdOperatorTable.EQUALS,builder.field("JOB"),builder.literal("DEVELOP")))
>       .project(builder.field("JOB"));
> }
> {code}
> The RelNode will generate the wrong Sql:
> {code:java}
> SELECT "JOB"
> FROM (SELECT "EMPNO", "ENAME", "JOB", COUNT(*) AS "C", SUM("SAL") AS "S"
> FROM "scott"."EMP"
> GROUP BY GROUPING SETS(("EMPNO", "ENAME"), "EMPNO")
> HAVING COUNT(*) > 10) AS "t0"
> WHERE "JOB" = 'DEVELOP'
> {code}
>  



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

Reply via email to