Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

planner: introduce the logical Expand for rollup syntax #44214

Closed
AilinKid opened this issue May 26, 2023 · 0 comments · Fixed by #44216
Closed

planner: introduce the logical Expand for rollup syntax #44214

AilinKid opened this issue May 26, 2023 · 0 comments · Fixed by #44216
Assignees
Labels
severity/minor sig/planner SIG: Planner type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@AilinKid
Copy link
Contributor

AilinKid commented May 26, 2023

Feature Request

Is your feature request related to a problem? Please describe:

Rollup syntax means the underlying data should always be replicated for N+1 times (N is equal to the number of group by items list size), Otherwise, rewriting them as multi-statements concat with the UNION clause is necessary which is not planned from our side.

So from the AST transformation, Logical Expand is necessary; besides, we also need some logical meta generated by Expand operator to do the groupingFunc rewrite, and this step is also should be done in the Logical phase.

tidb> explain select count(a) from t group by a, b with rollup;
+--------------------------------------+----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                                   | estRows  | task         | access object | operator info                                                                                                                                                                                                                 |
+--------------------------------------+----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| TableReader_43                       | 8000.00  | root         |               | MppVersion: 1, data:ExchangeSender_42                                                                                                                                                                                         |
| └─ExchangeSender_42                  | 8000.00  | mpp[tiflash] |               | ExchangeType: PassThrough                                                                                                                                                                                                     |
|   └─Projection_37                    | 8000.00  | mpp[tiflash] |               | Column#7                                                                                                                                                                                                                      |
|     └─HashAgg_35                     | 8000.00  | mpp[tiflash] |               | group by:Column#4, Column#5, gid, funcs:count(test.t.a)->Column#7                                                                                                                                                             |
|       └─ExchangeReceiver_21          | 10000.00 | mpp[tiflash] |               |                                                                                                                                                                                                                               |
|         └─ExchangeSender_20          | 10000.00 | mpp[tiflash] |               | ExchangeType: HashPartition, Compression: FAST, Hash Cols: [name: Column#4, collate: binary], [name: Column#5, collate: binary], [name: gid, collate: binary]                                                                 |
|           └─Expand_19                | 10000.00 | mpp[tiflash] |               | level-projection:[test.t.a, <nil>->Column#4, <nil>->Column#5, 0->gid],[test.t.a, Column#4, <nil>->Column#5, 2->gid],[test.t.a, Column#4, Column#5, 6->gid]; schema: [Column: [test.t.a,Column#4,Column#5,gid] Unique key: []] |
|             └─Projection_15          | 10000.00 | mpp[tiflash] |               | test.t.a, test.t.a, test.t.b                                                                                                                                                                                                  |
|               └─TableFullScan_16     | 10000.00 | mpp[tiflash] | table:t       | keep order:false, stats:pseudo                                                                                                                                                                                                |
+--------------------------------------+----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
9 rows in set (0.00 sec)

Describe the feature you'd like:

introduce the logical Expand for rollup syntax

Describe alternatives you've considered:

Union statements rewriting (NOT considered now)

Teachability, Documentation, Adoption, Migration Strategy:

None

@AilinKid AilinKid added the type/feature-request Categorizes issue or PR as related to a new feature. label May 26, 2023
@AilinKid AilinKid self-assigned this May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/minor sig/planner SIG: Planner type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant