-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
expression: refactor grouping function computation and update related tipb #44436
Conversation
/approve |
/LGTM |
@xzhangxian1008: adding LGTM is restricted to approvers and reviewers in OWNERS files. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@AilinKid: you cannot LGTM your own PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@AilinKid: Please do not delete or edit you lgtm type comment! In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/retest |
1 similar comment
/retest |
Signed-off-by: AilinKid <314806019@qq.com>
Signed-off-by: AilinKid <314806019@qq.com>
Signed-off-by: AilinKid <314806019@qq.com>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: guo-shaoge, wshwsh12, XuHuaiyu, xuyifangreeneyes, xzhangxian1008 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
/merge |
What problem does this PR solve?
Issue Number: close #44437
related tiflash issue : pingcap/tiflash#7590
related tipb pr: pingcap/tipb#308
Problem Summary:
add one more dimension for grouping marks maintenance.
ideas come from MySQL's support for grouping(a,b,c,...) with maximum of 64 parameters.
Notice the result difference of grouping(a,b) and grouping(b,a)!
mysql reference
As seen here, if GROUPING (a,b) returns 3, it means that NULL in column “a” and NULL in column “b” for that row is produce by a ROLLUP operation. If result is 1, NULL in column “b” alone is a result of ROLLUP operation.
https://dev.mysql.com/blog-archive/mysql-8-0-grouping-function/
when evaluating the grouping function's value, the formula is:
grouping(a,b,c) = grouping(a)<<2 + grouping(b)<<1 << grouping(c)
the left shift size is exactly according to their listed position in the grouping function.
so we should maintain all the grouping marks (for every single col) down, and add one more round computation for the left shift plus if the len(groupingMarks) is greater than 1 (means multi col args in grouping function).
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.