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

Need support window function push down to tiflash #3837

Closed
LittleFall opened this issue Jan 10, 2022 · 2 comments
Closed

Need support window function push down to tiflash #3837

LittleFall opened this issue Jan 10, 2022 · 2 comments
Assignees
Labels
type/feature-request Categorizes issue or PR as related to a new feature.

Comments

@LittleFall
Copy link
Contributor

LittleFall commented Jan 10, 2022

Feature Request

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

create table employee(empid int, deptid int, salary decimal(10,2));
insert into employee values(1,10,5500.00);
insert into employee values(2,10,4500.00);
insert into employee values(3,20,1900.00);
insert into employee values(4,20,4800.00);
insert into employee values(5,40,6500.00);
insert into employee values(6,40,14500.00);
insert into employee values(7,40,44500.00);
insert into employee values(8,50,6500.00);
insert into employee values(9,50,7500.00);
insert into employee values(10,10,3500.00);
insert into employee values(11,10,2500.00);
insert into employee values(12,20,3500.00);
insert into employee values(13,20,2500.00);
insert into employee values(14,40,3500.00);
insert into employee values(15,40,2500.00);
insert into employee values(16,50,3500.00);
insert into employee values(17,50,2500.00);


select *, row_number() over (partition by deptid ORDER BY salary desc) FROM employee;
+-------+--------+--------+--------------------------------------------------------------+
| empid | deptid | salary | row_number() OVER (PARTITION BY deptid ORDER BY salary DESC) |
+-------+--------+--------+--------------------------------------------------------------+
|     1 |     10 | 5500   |                                                            1 |
|     2 |     10 | 4500   |                                                            2 |
|    10 |     10 | 3500   |                                                            3 |
|    11 |     10 | 2500   |                                                            4 |
|     4 |     20 | 4800   |                                                            1 |
|    12 |     20 | 3500   |                                                            2 |
|    13 |     20 | 2500   |                                                            3 |
|     3 |     20 | 1900   |                                                            4 |
|     7 |     40 | 44500  |                                                            1 |
|     6 |     40 | 14500  |                                                            2 |
|     5 |     40 | 6500   |                                                            3 |
|    14 |     40 | 3500   |                                                            4 |
|    15 |     40 | 2500   |                                                            5 |
|     9 |     50 | 7500   |                                                            1 |
|     8 |     50 | 6500   |                                                            2 |
|    16 |     50 | 3500   |                                                            3 |
|    17 |     50 | 2500   |                                                            4 |
+-------+--------+--------+--------------------------------------------------------------+

alter table employee set tiflash replica 1;
set tidb_enforce_mpp=1;
desc select  *, row_number() over (partition by deptid ORDER BY salary desc) 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.deptid order by test.employee.salary desc rows between current row and current row) |
|   └─Sort_13                  | 17.00   | root         |                | test.employee.deptid, test.employee.salary:desc                                                                                            |
|     └─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.00 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------------------------------+
| Level   | Code | Message                                                                 |
+---------+------+-------------------------------------------------------------------------+
| Warning | 1105 | MPP mode may be blocked because operator `Window` is not supported now. |
| Warning | 1105 | MPP mode may be blocked because operator `Window` is not supported now. |
+---------+------+-------------------------------------------------------------------------+
2 rows in set (0.00 sec)

Describe the feature you'd like:

Describe alternatives you've considered:

Teachability, Documentation, Adoption, Migration Strategy:

@LittleFall LittleFall added the type/feature-request Categorizes issue or PR as related to a new feature. label Jan 10, 2022
@LittleFall
Copy link
Contributor Author

another syntax:

desc select /*+read_from_storage(tiflash[employee]) */  *, row_number() over w, max(deptid) over w from employee window w as  (partition by deptid);

@LittleFall
Copy link
Contributor Author

euqal to #4200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature-request Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants