[
https://issues.apache.org/jira/browse/CALCITE-5089?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17522484#comment-17522484
]
Julian Hyde commented on CALCITE-5089:
--------------------------------------
I reviewed PR 2771. Looks great. A few minor things I'd change:
* Rather than saying 'the GROUP_BY_DISTINCT operator is present' say 'the
DISTINCT keyword of GROUP BY is present'; tie it back to the SQL syntax, to
keep it real
* In the .iq file add tests for potentially tricky cases such as, 'GROUP BY
DISTINCT ()', 'GROUP BY ALL ()', 'GROUP BY DISTINCT x + y'
* In the parser I'd say 'list = new ImmutableList.of(groupByDIstinct)' rather
than creating an ArrayList
* In the parser, should the position of the GROUP_BY_DISTINCT call be the
position of just the DISTINCT keyword? (The SqlNodeList that represents the
GROUP BY clause should nevertheless be the whole thing, spanning GROUP BY to
the last item.)
Anyone else have comments? I'll merge this as soon as we have those changes.
> Allow GROUP BY ALL or DISTINCT set quantifier on GROUPING SETS
> --------------------------------------------------------------
>
> Key: CALCITE-5089
> URL: https://issues.apache.org/jira/browse/CALCITE-5089
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.30.0
> Environment: jdk8
> Reporter: yanjing.wang
> Assignee: yanjing.wang
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.31.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> GROUP BY DISTINCT will be used to remove duplicate GROUPING SETS, for example:
> {code:java}
> SELECT product_id, product_class_id, count(*) from product GROUP BY DISTINCT
> CUBE (product_id, product_class_id), ROLLUP (product_id,
> product_class_id){code}
> it's equivalent to
> {code:java}
> SELECT product_id, product_class_id, count(*) from product GROUP BY GROUPING
> SETS ((product_id, product_class_id), (product_id), (product_class_id), ())
> {code}
> GROUP BY ALL will remain the duplicate GROUPING SETS, it's equivalent to
> GROUP BY, so most databases use ALL as the default set quantifier.
> As far as I know the PostgreSQL and Trino support this syntax.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)