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) #16989

Closed

Conversation

sre-bot
Copy link
Contributor

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

cherry-pick #16591 to release-3.1


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.1-cherry-pick type/new-feature labels May 6, 2020
@sre-bot sre-bot added this to the v3.1.1 milestone May 6, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented May 8, 2020

@bb7133 bb7133 modified the milestones: v3.1.1, v3.1.2 May 9, 2020
@sre-bot
Copy link
Contributor Author

sre-bot commented May 10, 2020

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

@SunRunAway please resolve conflict and fix CI.

@zz-jason zz-jason added status/require-change and removed status/PTAL release-note Denotes a PR that will be considered when it comes time to generate release notes. labels May 12, 2020
@zz-jason zz-jason removed the request for review from francis0407 May 12, 2020 11:12
@SunRunAway
Copy link
Contributor

SunRunAway commented May 13, 2020

Close it and cherry-pick manually in #17184.

@SunRunAway SunRunAway closed this May 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants