[
https://issues.apache.org/jira/browse/CALCITE-4697?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17382663#comment-17382663
]
Julian Hyde commented on CALCITE-4697:
--------------------------------------
Derby is usually pretty good but it’s not definitive.
As far as I am aware GROUPING\(x) is equivalent to GROUPING_ID\(x) for any
expression x. If you know of an expression that breaks that rule on Oracle or
PostgreSQL, can you post it.
> GROUPING_ID may be distinct from GROUPING
> -----------------------------------------
>
> Key: CALCITE-4697
> URL: https://issues.apache.org/jira/browse/CALCITE-4697
> Project: Calcite
> Issue Type: Bug
> Reporter: Will Noble
> Priority: Minor
>
> See [CALCITE-1652|https://issues.apache.org/jira/browse/CALCITE-1652].
> I'm having trouble finding the exact text of the SQL Standard 2014, so
> perhaps this bug is a dud, but I believe these two agg functions may have
> different return values. I think we can all agree on the behavior of the
> {{GROUPING_ID}} function, which returns a bitmap where the {{n}}th bit is
> high iff the {{n}}th argument is grouped, but according to at least [this
> documentation|https://cwiki.apache.org/confluence/display/DERBY/OLAPGroupingOperation],
> the {{GROUPING}} function returns "1 if the values in this row are the
> results of aggregating over (possibly) multiple values of that column, and 0
> if they are not". Also note that the author goes on to say "Does the above
> table make sense? I'm not sure I'm understanding the GROUPING operation
> correctly", so this claim must be verified.
> If true, that means these functions are not equivalent because {{GROUPING}}
> would return essentially a boolean value indicating if _all_ the argument
> columns are grouped, whereas {{GROUPING_ID}} would return a more nuanced
> integer value indicating if _each_ of the arguments are grouped, and
> therefore {{GROUPING_ID}} should not be deprecated and should not be treated
> as an alias for {{GROUPING}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)