[MCOL-3267] Support ORDER BY within UNION subqueries Created: 2019-04-17 Updated: 2020-08-25 Resolved: 2019-04-26 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | 1.2.4 |
| Type: | New Feature | Priority: | Major |
| Reporter: | Andrew Hutchings (Inactive) | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 3 |
| Labels: | None | ||
| Sprint: | 2019-04 |
| Description |
|
We do not support ORDER BY within subqueries that are unioned, for example:
|
| Comments |
| Comment by Roman [ 2019-04-22 ] | ||||||||||||
|
create table t1 (a bigint, b bigint)engine=columnstore; SELECT * FROM( This query produces expected results. LimitedOrderBy got called three times as expected. And if I add ORDER BY at the top level then filesort comes into play. | ||||||||||||
| Comment by Roman [ 2019-04-23 ] | ||||||||||||
|
Please review the change. | ||||||||||||
| Comment by Roman [ 2019-04-23 ] | ||||||||||||
|
For QA: Here are the steps to reproduce the issue. create table t1 (a bigint, b bigint)engine=columnstore; SELECT * FROM | ||||||||||||
| Comment by Daniel Lee (Inactive) [ 2019-04-25 ] | ||||||||||||
|
Reproduced the issue on 1.2.3-1 It is not yet fixed in last nights 1.2.4-1 nightly. It looks like it was merged after the build was made. The SELECT statement in the last comment has an extra comma in the 2nd subquery. | ||||||||||||
| Comment by Daniel Lee (Inactive) [ 2019-04-26 ] | ||||||||||||
|
Build verified: 1.2.4-1 nightly server commit: Reproduced incorrect result issue in 1.2.3-1: Welcome to the MariaDB monitor. Commands end with ; or \g. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [mytest]> SELECT * FROM ((SELECT a, b FROM t1 ORDER BY b LIMIT 2) UNION ALL (SELECT a, b FROM t2 ORDER BY b LIMIT 2)) as sq3 ORDER BY 1,2;
-----
----- 1.2.4-1 Welcome to the MariaDB monitor. Commands end with ; or \g. Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [mytest]> SELECT * FROM ((SELECT a, b FROM t1 ORDER BY b LIMIT 2) UNION ALL (SELECT a, b FROM t2 ORDER BY b LIMIT 2)) as sq3 ORDER BY 1,2;
-----
----- |