What happened
Dolt evaluates a legal NOT EXISTS predicate incorrectly when its correlated equality compares an outer row to the id projected by a derived table that also computes ROW_NUMBER(). The window must rank both input rows before the correlated predicate is applied. Dolt instead behaves as if the derived window sees only the one row selected by the outer id lookup, so every row receives rn = 1 and the anti-join removes every outer row.
The witness uses only ordinary signed INT values, a legal ORDER BY, and a legal ROW_NUMBER window. It does not use CAST, JSON, BIGINT, floating point, precision boundaries, GIS, binary values, or type coercion.
Environment
Dolt main (commit c3b5ce3c67f8677ca08a0a58d8c03cdc95bff8b7). MySQL version 8.0.43.
How to reproduce
Run the corresponding SQL in a fresh Dolt repository.
CREATE TABLE t(id INT PRIMARY KEY, k INT);
INSERT INTO t VALUES (1, 10), (2, 20);
SELECT o.id
FROM t AS o
WHERE NOT EXISTS (
SELECT 1
FROM (
SELECT id, ROW_NUMBER() OVER (ORDER BY k, id) AS rn
FROM t
) AS w
WHERE w.id = o.id AND w.rn <= 1
)
ORDER BY o.id;
Expected Result
The two input rows sort as (id,k) = (1,10),(2,20). Therefore the derived window has rn = 1 for id=1 and rn = 2 for id=2. The NOT EXISTS condition removes only id=1, so the expected result is:
Dolt actual result
Dolt exits successfully but returns an empty result set:
What happened
Dolt evaluates a legal
NOT EXISTSpredicate incorrectly when its correlated equality compares an outer row to theidprojected by a derived table that also computesROW_NUMBER(). The window must rank both input rows before the correlated predicate is applied. Dolt instead behaves as if the derived window sees only the one row selected by the outeridlookup, so every row receivesrn = 1and the anti-join removes every outer row.The witness uses only ordinary signed
INTvalues, a legalORDER BY, and a legalROW_NUMBERwindow. It does not use CAST, JSON, BIGINT, floating point, precision boundaries, GIS, binary values, or type coercion.Environment
Dolt main (commit
c3b5ce3c67f8677ca08a0a58d8c03cdc95bff8b7). MySQL version 8.0.43.How to reproduce
Run the corresponding SQL in a fresh Dolt repository.
Expected Result
The two input rows sort as
(id,k) = (1,10),(2,20). Therefore the derived window hasrn = 1forid=1andrn = 2forid=2. TheNOT EXISTScondition removes onlyid=1, so the expected result is:Dolt actual result
Dolt exits successfully but returns an empty result set: