dolthub / dolthub/dolt

Top-level `ORDER BY` does not seem to be applied to unions

Open
#11,714 0 comments 0 reactions 0 assignees View on GitHub
analyzer bug correctness sql
Dominant language
Go
Stars
24.5k
Forks
873
Avg merge
1d 8h
Merged PRs (30d)
120

Description

MySQL
```
mysql> select 1000 union select 1 order by 1;
+------+
| 1000 |
+------+
| 1 |
| 1000 |
+------+
2 rows in set (0.00 sec)

mysql> select 1000 union (select 1 order by 1);
+------+
| 1000 |
+------+
| 1000 |
| 1 |
+------+
2 rows in set (0.00 sec)
```

Dolt
```
tmp/main*> select 1000 union select 1 order by 1;
+------+
| 1000 |
+------+
| 1000 |
| 1 |
+------+
2 rows in set (0.00 sec)

tmp/main*> select 1000 union (select 1 order by 1);
+------+
| 1000 |
+------+
| 1000 |
| 1 |
+------+
2 rows in set (0.00 sec)
```

Contributor guide

No contributing guide indexed for this repository

Research direction

No repository files or tests are named. Reproduce both UNION queries in Dolt and trace the SQL UNION and top-level ORDER BY handling, comparing the results with MySQL; done means both queries apply ordering as shown by MySQL and regression tests cover them.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, mysql, sql
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.