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

Ruben Q L commented on CALCITE-6531:
------------------------------------

Thanks for checking [~julianhyde] .
PostgreSQL's 
[documentation|https://www.postgresql.org/docs/9.5/functions-aggregate.html#FUNCTIONS-GROUPING-TABLE]
 seems to go in the same direction as well: 

bq. Bits are assigned with the rightmost argument being the least-significant 
bit; each bit is 0 if the corresponding expression is included in the grouping 
criteria of the grouping set generating the result row, and 1 if it is not.

> Correct Javadoc example in SqlStaticAggFunction#constant
> --------------------------------------------------------
>
>                 Key: CALCITE-6531
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6531
>             Project: Calcite
>          Issue Type: Task
>          Components: core
>    Affects Versions: 1.35.0, 1.36.0, 1.37.0
>            Reporter: Ruben Q L
>            Priority: Minor
>             Fix For: 1.38.0
>
>
> The Javadoc in SqlStaticAggFunction#constant says:
> {noformat}
> GROUPING(deptno) expands to literal 1 if the aggregate has GROUP BY deptno
> {noformat}
> However, this "1" seems incorrect (it should rather be "0"). If we look at 
> the actual implementation of this logic in 
> [SqlGroupingFunction#constant|https://github.com/apache/calcite/blob/e4bbcd6f53ff6be2e2be0893b94d3806e58278d2/core/src/main/java/org/apache/calcite/sql/fun/SqlGroupingFunction.java#L62],
>  or [this test 
> agg.iq|https://github.com/apache/calcite/blob/e4bbcd6f53ff6be2e2be0893b94d3806e58278d2/core/src/test/resources/sql/agg.iq#L689],
>  it seems in these cases the GROUPING is expanded to a constant 0.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to