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: support push window function down to tiflash #31601

Merged
merged 54 commits into from
May 13, 2022

Conversation

LittleFall
Copy link
Contributor

@LittleFall LittleFall commented Jan 12, 2022

What problem does this PR solve?

Issue Number: close #33072

Problem Summary:

What is changed and how it works?

design doc: https://pingcap.feishu.cn/wiki/wikcn9SxkYnjepzI35q5munvsbc#yWGRKu (will public to github later)

  • support push down window function to tiflash.
  • support blacklist of window function desc(see tests below).
  • only support RowNumber, Rank, DenseRank now.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
mysql> explain select *, row_number() over (partition by empid order by salary) FROM employee;
+----------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
| id                               | estRows | task         | access object  | operator info                                                                                                                        |
+----------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
| TableReader_24                   | 17.00   | root         |                | data:ExchangeSender_23                                                                                                               |
| └─ExchangeSender_23              | 17.00   | cop[tiflash] |                | ExchangeType: PassThrough                                                                                                            |
|   └─Window_22                    | 17.00   | cop[tiflash] |                | row_number()->Column#6 over(partition by test.employee.empid order by test.employee.salary rows between current row and current row) |
|     └─Sort_13                    | 17.00   | cop[tiflash] |                | test.employee.empid, test.employee.salary                                                                                            |
|       └─ExchangeReceiver_12      | 17.00   | cop[tiflash] |                |                                                                                                                                      |
|         └─ExchangeSender_11      | 17.00   | cop[tiflash] |                | ExchangeType: HashPartition, Hash Cols: [name: test.employee.empid, collate: N/A]                                                    |
|           └─TableFullScan_10     | 17.00   | cop[tiflash] | table:employee | keep order:false, stats:pseudo                                                                                                       |
+----------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
7 rows in set (0.00 sec)

mysql> table mysql.expr_pushdown_blacklist;
+----------+------------+--------------------------------------------------------------------+
| name     | store_type | reason                                                             |
+----------+------------+--------------------------------------------------------------------+
| date_add | tiflash    | DST(daylight saving time) does not take effect in TiFlash date_add |
+----------+------------+--------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> insert into mysql.expr_pushdown_blacklist values ("row_number", "tiflash", "test");
Query OK, 1 row affected (0.01 sec)

mysql> admin reload expr_pushdown_blacklist;
Query OK, 0 rows affected (0.00 sec)

mysql> explain select *, row_number() over (partition by empid order by salary) FROM employee;
+------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
| id                           | estRows | task         | access object  | operator info                                                                                                                        |
+------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
| Shuffle_14                   | 17.00   | root         |                | execution info: concurrency:5, data sources:[TableReader_12]                                                                         |
| └─Window_8                   | 17.00   | root         |                | row_number()->Column#6 over(partition by test.employee.empid order by test.employee.salary rows between current row and current row) |
|   └─Sort_13                  | 17.00   | root         |                | test.employee.empid, test.employee.salary                                                                                            |
|     └─TableReader_12         | 17.00   | root         |                | data:TableFullScan_11                                                                                                                |
|       └─TableFullScan_11     | 17.00   | cop[tiflash] | table:employee | keep order:false, stats:pseudo                                                                                                       |
+------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
5 rows in set, 2 warnings (0.01 sec)

mysql> show warnings ;
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level   | Code | Message                                                                                                                                                  |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1105 | MPP mode may be blocked because window function `row_number` is blocked by blacklist, check `table mysql.expr_pushdown_blacklist;` for more information. |
| Warning | 1105 | MPP mode may be blocked because window function `row_number` is blocked by blacklist, check `table mysql.expr_pushdown_blacklist;` for more information. |
+---------+------+----------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> delete from mysql.expr_pushdown_blacklist;
Query OK, 2 rows affected (0.00 sec)

mysql> admin reload expr_pushdown_blacklist;
Query OK, 0 rows affected (0.01 sec)

mysql> explain select *, row_number() over (partition by empid order by salary) FROM employee;
+----------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
| id                               | estRows | task         | access object  | operator info                                                                                                                        |
+----------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
| TableReader_24                   | 17.00   | root         |                | data:ExchangeSender_23                                                                                                               |
| └─ExchangeSender_23              | 17.00   | cop[tiflash] |                | ExchangeType: PassThrough                                                                                                            |
|   └─Window_22                    | 17.00   | cop[tiflash] |                | row_number()->Column#6 over(partition by test.employee.empid order by test.employee.salary rows between current row and current row) |
|     └─Sort_13                    | 17.00   | cop[tiflash] |                | test.employee.empid, test.employee.salary                                                                                            |
|       └─ExchangeReceiver_12      | 17.00   | cop[tiflash] |                |                                                                                                                                      |
|         └─ExchangeSender_11      | 17.00   | cop[tiflash] |                | ExchangeType: HashPartition, Hash Cols: [name: test.employee.empid, collate: N/A]                                                    |
|           └─TableFullScan_10     | 17.00   | cop[tiflash] | table:employee | keep order:false, stats:pseudo                                                                                                       |
+----------------------------------+---------+--------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------+
7 rows in set (0.00 sec)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Jan 12, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • Yisaer
  • fzhedu

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added do-not-merge/needs-linked-issue release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 12, 2022
@LittleFall LittleFall marked this pull request as draft January 12, 2022 05:45
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 12, 2022
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 12, 2022
@ti-chi-bot ti-chi-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 18, 2022
@LittleFall LittleFall marked this pull request as ready for review January 22, 2022 06:08
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 22, 2022
@LittleFall LittleFall marked this pull request as draft January 22, 2022 06:09
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 22, 2022
@ti-chi-bot ti-chi-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 24, 2022
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 11, 2022
@LittleFall LittleFall requested a review from fzhedu May 13, 2022 02:59
@LittleFall
Copy link
Contributor Author

/run-realtikv-test

@LittleFall
Copy link
Contributor Author

/run-realtikv-test (pull_request)

@LittleFall
Copy link
Contributor Author

/run-mysql-test

@LittleFall
Copy link
Contributor Author

/run-check_dev_2

@LittleFall
Copy link
Contributor Author

/run-mysql-test

@sre-bot
Copy link
Contributor

sre-bot commented May 13, 2022

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 13, 2022
Copy link
Contributor

@fzhedu fzhedu left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 13, 2022
@fzhedu
Copy link
Contributor

fzhedu commented May 13, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: b7ac3c5

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 13, 2022
@LittleFall LittleFall merged commit 1c6dcf0 into pingcap:master May 13, 2022
@LittleFall LittleFall deleted the dev/window branch May 13, 2022 06:12
@sre-bot
Copy link
Contributor

sre-bot commented May 13, 2022

TiDB MergeCI notify

✅ Well Done! New fixed [1] after this pr merged.

CI Name Result Duration Compare with Parent commit
idc-jenkins-ci-tidb/common-test ✅ all 12 tests passed 7 min 33 sec Fixed
idc-jenkins-ci/integration-cdc-test 🟢 all 34 tests passed 28 min Existing passed
idc-jenkins-ci-tidb/integration-common-test 🟢 all 11 tests passed 12 min Existing passed
idc-jenkins-ci-tidb/tics-test 🟢 all 1 tests passed 10 min Existing passed
idc-jenkins-ci-tidb/integration-ddl-test 🟢 all 6 tests passed 7 min 46 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-2 🟢 all 28 tests passed 6 min 21 sec Existing passed
idc-jenkins-ci-tidb/sqllogic-test-1 🟢 all 26 tests passed 5 min 47 sec Existing passed
idc-jenkins-ci-tidb/mybatis-test 🟢 all 1 tests passed 4 min 42 sec Existing passed
idc-jenkins-ci-tidb/integration-compatibility-test 🟢 all 1 tests passed 3 min 30 sec Existing passed
idc-jenkins-ci-tidb/plugin-test 🟢 build success, plugin test success 4min Existing passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support window function push down to tiflash
6 participants