Skip to content

support GROUP BY modifiers #4250

Closed
Closed

Description

@zz-jason

Request Description

MySQL and Oracle support ROLLUP modifier, SQL Server also supports CUBE and GROUPING SETS

References:

An example in MySQL:

drop table if exists t;
create table t(a bigint, b bigint, c bigint);
insert into t values(1, 2, 3), (2, 2, 3), (3, 2, 3);
MySQL > select a, min(b) from t group by a with rollup;
+------+--------+
| a    | min(b) |
+------+--------+
|    1 |      2 |
|    2 |      2 |
|    3 |      2 |
| NULL |      2 |
+------+--------+
4 rows in set (0.01 sec)

Category

Feature

Value

  • Value Point: 2

It's hard to tell the value for now. Quoted from https://docs.oracle.com/cd/F49540_01/DOC/server.815/a68003/rollup_c.htm:

One of the key concepts in decision support systems is "multi-dimensional analysis": examining the enterprise from all necessary combinations of dimensions. We use the term "dimension" to mean any category used in specifying questions. Among the most commonly specified dimensions are time, geography, product, department, and distribution channel, but the potential dimensions are as endless as the varieties of enterprise activity. The events or entities associated with a particular set of dimension values are usually referred to as "facts." The facts may be sales in units or local currency, profits, customer counts, production volumes, or anything else worth tracking.

I think the value of this request is to improve the usability and performance in Business Intelligence(BI) scenarios. No need to run several aggregate queries to get another level aggregate result. I'm curious about whether are some BI tools rely on this feature.

Workload Estimation

Workload contains coding, documenting, and testing.
1 Point for 1 Person/Work Day

  • 60 Points, hard to say, most modifications are on the aggregate operator in execution engine.

Activity

  1. self-assigned this
    on Aug 19, 2017
  2. Lloyd-longfei commented on Mar 8, 2018

    @Lloyd-longfei

    My also encountered the same problem with TIDB, and when writing SQL, the following mistakes were made:

    Error : line 83 column 35 near " rollup" (total length 3865) 
    

    This problem may directly affect the running of our online production environment, when can you increase the function, or tell us how to solve the problem. @hanfei1991

  3. zz-jason commented on Mar 8, 2018

    @zz-jason
    MemberAuthor

    @Lloyd-longfei Thanks for your feed back, I'm sorry to tell you that group by ... with rollup is not on our roadmap now, but we'll support it as soon as possible.

    For now, a workaround is to write another sql to get the aggregation summary, see https://dev.mysql.com/doc/refman/5.7/en/group-by-modifiers.html for more detail.

  4. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Mar 18, 2018
  5. morgo commented on Dec 29, 2018

    @morgo
    Contributor

    Confirming that this feature is still missing:

    mysql> select a, min(b) from t group by a with rollup;
    ERROR 1105 (HY000): line 1 column 39 near " rollup" (total length 46)
    mysql> select tidb_version();
    +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | tidb_version()                                                                                                                                                                                                                                                                                                                      |
    +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    | Release Version: v2.1.0-rc.3-385-gbb0e7a18f
    Git Commit Hash: bb0e7a18f63b12b167eb1c5ba58bcf4cb6ea7a1b
    Git Branch: socket
    UTC Build Time: 2018-12-29 10:14:15
    GoVersion: go version go1.11.4 linux/amd64
    Race Enabled: false
    TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
    Check Table Before Drop: false |
    +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
    1 row in set (0.00 sec)
    
  6. vkingnew commented on Mar 28, 2019

    @vkingnew

    this feature is still not support as tidb 2.1.7,and which version to support ROLLUP and CUBE

    mysql> select tidb_version()\G
    *************************** 1. row ***************************
    tidb_version(): Release Version: v2.1.7
    Git Commit Hash: f5b52cb
    Git Branch: HEAD
    UTC Build Time: 2019-03-28 07:54:41
    GoVersion: go version go1.11.2 linux/amd64
    Race Enabled: false
    TiKV Min Version: 2.1.0-alpha.1-ff3dd160846b7d1aed9079c389fc188f7f5ea13e
    Check Table Before Drop: false
    1 row in set (0.00 sec)

  7. added
    type/feature-requestCategorizes issue or PR as related to a new feature.
    and removed
    type/enhancementThe issue or PR belongs to an enhancement.
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Mar 23, 2020
  8. removed their assignment
    on Apr 3, 2020
  9. added
    help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
    on Jul 21, 2020
  10. bhzhu203 commented on May 6, 2021

    @bhzhu203

    TiDB-v5.0.0 still does not support the "ROLLUP" fuction. Our product managers and staff managers like to write the BI statistics queries with the "ROLLUP" fuction , and hard to remove all of the "ROLLUP" from the losts of queries .
    The replacement of the "ROLLUP" fuction costs a lot. The "ROLLUP" fuction exists in our BI queries over 40% . We still using the slow mysql instance because that. Hope TiDB will support "ROLLUP" . Thanks

    rollup-sample.sql.gz

  11. Enochack commented on May 11, 2021

    @Enochack

    /pick

  12. Enochack commented on May 11, 2021

    @Enochack

    /assign

  13. Defined2014 commented on Aug 20, 2024

    @Defined2014
    Contributor

    We already supported rollup right now, ref #42631 . So close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

feature/acceptedThis feature request is accepted by product managershelp wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.sig/executionSIG executiontype/feature-requestCategorizes issue or PR as related to a new feature.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions