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

[jira] [Commented] (HIVE-15996) Implement multiargument GROUPING function

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

Julian Hyde commented on HIVE-15996:
------------------------------------

I was mistaken about {{GROUP_ID()}} being equivalent to {{GROUPING(x, y, z)}} (assuming the query has {{GROUP BY x, y, z}}).
In fact, {{GROUP_ID()}} should return zero unless you have a query with duplicate grouping sets (which is very unusual).
Furthermore, {{GROUP_ID()}} is Oracle-specific and non-standard.
See CALCITE-1824 for more details.

> Implement multiargument GROUPING function
> -----------------------------------------
>
>                 Key: HIVE-15996
>                 URL: https://issues.apache.org/jira/browse/HIVE-15996
>             Project: Hive
>          Issue Type: New Feature
>    Affects Versions: 2.2.0
>            Reporter: Carter Shanklin
>            Assignee: Jesus Camacho Rodriguez
>             Fix For: 3.0.0
>
>         Attachments: HIVE-15996.01.patch, HIVE-15996.02.patch, HIVE-15996.03.patch, HIVE-15996.04.patch
>
>
> Per the SQL standard section 6.9:
> GROUPING ( CR1, ..., CRN-1, CRN )
> is equivalent to:
> CAST ( ( 2 * GROUPING ( CR1, ..., CRN-1 ) + GROUPING ( CRN ) ) AS IDT )
> So for example:
> select c1, c2, c3, grouping(c1, c2, c3) from e011_02 group by rollup(c1, c2, c3);
> Should be allowed and equivalent to:
> select c1, c2, c3, 4*grouping(c1) + 2*grouping(c2) + grouping(c3) from e011_02 group by rollup(c1, c2, c3);



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)