Jiajun Xie created CALCITE-5525:
-----------------------------------

             Summary: GROUPING_ID() should be rewritten to GROUPING() in some 
dialects
                 Key: CALCITE-5525
                 URL: https://issues.apache.org/jira/browse/CALCITE-5525
             Project: Calcite
          Issue Type: Improvement
          Components: core
            Reporter: Jiajun Xie
            Assignee: Jiajun Xie


Some databases not exists `grouping_id()`, `grouping()` is used as 
`grouping_id()`.
 - Postgresql
{code:java}
ERROR:  function grouping_id(integer, character varying) does not exist
LINE 1: select grouping(id), grouping(name), grouping_id(id, name), ...
                                             ^
HINT:  No function matches the given name and argument types. You might need to 
add explicit type casts
{code}

 - Presto
{code:java}
Function grouping_id not registered
{code}

 

Here is a simple query, `grouping_id()` is a legal function in Spark.
{code:java}
select  a,
        b,
        count(*),
        grouping(a) ga,
        grouping(b) gb,
        grouping_id(a, b)
from    (
            select  1 as a, 2 as b
        )
group by grouping sets((a, b), (b), ())
{code}



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

Reply via email to