Dolt LAST_VALUE uses a ROWS-like implicit frame instead of the default RANGE peer frame
Author: Yibo-DongCreated Sep 15, 2026Updated Sep 16, 2026
Labelsbuggood reprocustomer issuecorrectness
What happened
For legal peer rows, Dolt's implicit LAST_VALUE frame differs from the explicitly written SQL default frame, although the two forms are semantically equivalent.
Environment
Dolt main (commit 92baa5e78afd013b42a62d21b05da0481031e8d0). MySQL version 8.0.43.
How to reproduce
Run the corresponding SQL in a fresh Dolt repository.
CREATE TABLE t(id INT PRIMARY KEY, x INT, v INT);
INSERT INTO t VALUES (1,1,10),(2,1,20),(3,2,30);
SELECT id, x, v,
LAST_VALUE(v) OVER (ORDER BY x) AS implicit_frame,
LAST_VALUE(v) OVER (
ORDER BY x
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) AS explicit_equivalent
FROM t
ORDER BY id;Expected Result
The exact SQL above was run against MySQL 8.0.43. MySQL returned:
1 1 10 20 20
2 1 20 20 20
3 2 30 30 30With an ordered window and no explicit frame, the SQL default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW. Both x=1 peers therefore have the same frame endpoint.
Dolt actual
Dolt returned:
1 1 10 10 20
2 1 20 20 20
3 2 30 30 30Dolt #11398 concerns an explicit RANGE frame with a NULL key. I guess they are not duplicates.
Source: dolthub/dolt