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

executor: support GROUP_CONCAT(ORDER BY) (#16591) #16988

Merged
merged 11 commits into from
May 8, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented May 6, 2020

cherry-pick #16591 to release-3.0


What problem does this PR solve?

Issue Number: close #6838

Problem Summary:

What is changed and how it works?

Proposal: xxx

What's Changed:

Executor part:

  1. Add a heap in GROUP_CONCAT function implementation.
  2. Build hash agg in unparalleled if group_concat has ORDER BY clause.

Planner part:

  1. Build and resolve arguments of ORDER BY clause.
  2. Add explain info with ORDER BY clause.
  3. Handle arguments of ORDER BY clause in ResolveIndices, PruneColumns and InjectProjBelowAgg
  4. Do not push down to coprocessor if group_concat has ORDER BY clause.
  5. Do not push down to Union and Join if group_concat has ORDER BY clause.

How it Works:

mysql> desc select 1, 2, 3, 4, 5 , group_concat(name, id ORDER BY 2 desc, name SEPARATOR '++') from test;
+------------------------------+---------+-----------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| id                           | estRows | task      | access object | operator info                                                                                                                                        |
+------------------------------+---------+-----------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Projection_4                 | 1.00    | root      |               | 1->Column#5, 2->Column#6, 3->Column#7, 4->Column#8, 5->Column#9, Column#4                                                                            |
| └─StreamAgg_8                | 1.00    | root      |               | funcs:group_concat(Column#15, Column#16 order by Column#17 desc, Column#18 asc separator "++")->Column#4                                             |
|   └─Projection_18            | 6.00    | root      |               | cast(test.test.name, var_string(20))->Column#15, cast(test.test.id, var_string(20))->Column#16, test.test.name->Column#17, test.test.name->Column#18 |
|     └─TableReader_15         | 6.00    | root      |               | data:TableFullScan_14                                                                                                                                |
|       └─TableFullScan_14     | 6.00    | cop[tikv] | table:test    | keep order:false, stats:pseudo                                                                                                                       |
+------------------------------+---------+-----------+---------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
5 rows in set (0.00 sec)

mysql> select 1, 2, 3, 4, 5 , group_concat(name, id ORDER BY 2 desc, name SEPARATOR '++') from test;
+---+---+---+---+---+-------------------------------------------------------------+
| 1 | 2 | 3 | 4 | 5 | group_concat(name, id ORDER BY 2 desc, name SEPARATOR '++') |
+---+---+---+---+---+-------------------------------------------------------------+
| 1 | 2 | 3 | 4 | 5 | 5003++2003++301++201++202++101                              |
+---+---+---+---+---+-------------------------------------------------------------+
1 row in set (0.00 sec)

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Performance regression
    • Consumes more MEM

Release note

  • support ORDER BY clause in GROUP_CONCAT

Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor Author

sre-bot commented May 6, 2020

/run-all-tests

@sre-bot sre-bot added sig/execution SIG execution component/expression sig/planner SIG: Planner release-note Denotes a PR that will be considered when it comes time to generate release notes. status/PTAL type/3.0-cherry-pick type/new-feature labels May 6, 2020
@sre-bot sre-bot added this to the v3.0.14 milestone May 6, 2020
@SunRunAway
Copy link
Contributor

/run-all-tests

@SunRunAway
Copy link
Contributor

/run-all-tests

@SunRunAway SunRunAway added the priority/release-blocker This issue blocks a release. Please solve it ASAP. label May 7, 2020
Copy link
Contributor

@qw4990 qw4990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@qw4990 qw4990 added the status/LGT1 Indicates that a PR has LGTM 1. label May 8, 2020
Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@SunRunAway
Copy link
Contributor

/merge

@sre-bot sre-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 8, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented May 8, 2020

/run-all-tests

@sre-bot sre-bot merged commit 8885168 into pingcap:release-3.0 May 8, 2020
SunRunAway pushed a commit to SunRunAway/tidb that referenced this pull request May 13, 2020
@SunRunAway SunRunAway modified the milestones: v3.0.14, v3.0.15 May 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/expression priority/release-blocker This issue blocks a release. Please solve it ASAP. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/execution SIG execution sig/planner SIG: Planner status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. type/new-feature type/3.0-cherry-pick
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants