Dolt reverses the direction of a numeric `DESC RANGE` offset frame
- Dominant language
- Go
- Stars
- 24.4k
- Forks
- 873
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 108
Description
## What happened
Dolt reverses the direction of a numeric `DESC RANGE` offset frame.
## Environment
Dolt main commit `91b1a7043126313a349503269230b874afdf8ded` (`dolt version 2.2.3`).
## How to reproduce
```sql
CREATE TABLE t(id INT PRIMARY KEY,k INT,v INT);
INSERT INTO t VALUES (1,1,10),(2,2,20),(3,3,30);
SELECT id,SUM(v) OVER (
ORDER BY k DESC RANGE BETWEEN 1 PRECEDING AND CURRENT ROW
) AS x FROM t ORDER BY id;
```
This is a legal numeric `RANGE BETWEEN 1 PRECEDING AND CURRENT ROW` frame with descending order.
## Expected result
MySQL 8.0.43 returns the following result. For descending order, `1 PRECEDING` covers the current key through the next higher key in value order:
```text
id x
1 30
2 50
3 30
```
## Actual result
Dolt returns:
```text
id x
1 60
2 60
3 60
```
It widens every frame to the partition.
Contributor guide
No contributing guide indexed for this repository
Research direction
Run the SQL reproduction against Dolt and compare its descending numeric RANGE frame results with the expected MySQL output. Trace the window-function frame handling for DESC ordering, add a regression test for this query, and consider the issue done when the results are 30, 50, and 30 rather than 60 for every row.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 70/100