Dolt rejects a repeated window expression in `ORDER BY` as ambiguous.
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 120
Description
## What happened
Dolt rejects a direct repetition of a window expression in the same query's `ORDER BY` with an ambiguous column/alias resolution error.
MySQL accepts the repeated expression and returns rows ordered by the window value.
## Environment
Dolt main at commit `a995f245c032bc412aed308194d81ee12bc74f19` (`dolt version 2.2.3`).
## How to reproduce
In a fresh Dolt repository, run:
```sql
CREATE TABLE t(id INT PRIMARY KEY, g INT, v INT NOT NULL);
INSERT INTO t VALUES (1, 0, 10), (2, 0, -2);
SELECT id, g,
SUM(v) OVER (
PARTITION BY g ORDER BY id ASC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS wf
FROM t
ORDER BY SUM(v) OVER (
PARTITION BY g ORDER BY id ASC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
), id;
```
## Expected result
MySQL 8.0.43 returns:
```text
id g wf
2 0 8
1 0 10
```
## Actual result
The source repeats the running `SUM` window expression directly in `ORDER BY`. It fails with:
```text
ambiguous column or alias name "sum ... over (...) ... t.v"
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.