Repository navigation
Description
Description
MatrixOne accepts the default semantics of LAG() and NTH_VALUE(), but rejects two explicit forms that MySQL accepts and defines as those defaults:
RESPECT NULLSfor value window functions.FROM FIRSTforNTH_VALUE().
This prevents MySQL SQL that spells out its intended default window semantics from running unchanged on MatrixOne.
Environment
- Branch:
main - Commit:
17c161a31b47a22e71ca222839143f66717ac365 - Deployment: local single-CN MatrixOne service
Steps to reproduce
CREATE DATABASE win_mysql_probe;
USE win_mysql_probe;
CREATE TABLE t (id INT PRIMARY KEY, g INT, ordv INT, v INT);
INSERT INTO t VALUES (1,1,1,10), (2,1,2,20), (3,1,2,30), (4,2,1,40);
SELECT LAG(v) RESPECT NULLS OVER (PARTITION BY g ORDER BY ordv) FROM t;
SELECT NTH_VALUE(v, 2) FROM FIRST OVER (PARTITION BY g ORDER BY ordv) FROM t;Actual behavior
Both statements are rejected during parsing:
syntax error near "respect nulls over(...)"
syntax error near "from first over(...)"
Expected behavior
Accept both forms with MySQL semantics:
RESPECT NULLSis the default null treatment.FROM FIRSTis the default direction forNTH_VALUE().
For the fixture above, the controls without the explicit modifiers run successfully and produce the same results: LAG(v) yields 10,20 for the non-NULL rows in the first partition, and NTH_VALUE(v,2) yields 20,20,20 there.
Stability and scope
- The two parser rejections and the controls reproduced 3/3 on the commit above.
IGNORE NULLS,FROM LAST,GROUPS, andEXCLUDEare intentionally out of scope: MySQL itself documents those forms as rejected or unsupported.RANGE ? PRECEDINGis separately tracked by [Compatibility]: prepared RANGE window-frame bounds reject parameter markers #28022.
Code analysis
pkg/sql/parsers/dialect/mysql/mysql_sql.y defines the value-window forms without optional null-treatment or direction modifiers. The default function implementations are present; the gap is in accepted MySQL grammar.
Regression coverage
After implementation, add deterministic SQL coverage under test/distributed/cases/window for both explicit forms and their default-form equivalence.
Activity
fix(parser): support explicit default window modifiers (#28064)
slyunnn commentedon Sep 4, 2026
Regression and extended verification for #28031 (2026-09-04)
Verification Environment
mainand refreshed localorigin/main:bf63172c0691e917ed2613c2d3a2d3d76a7f682e—perf(load): add opt-in parquet parallel-load groundwork (#27903).HEADwas a detached older checkout at17c161a31b47a22e71ca222839143f66717ac365; it was not used as the final baseline. Verification used an isolated worktree at the exact refreshedorigin/maincommit.fix(parser): support explicit default window modifiers, merge commit97a7f7f155a4042dc1e65d12599f18f91ad364d2. This commit is reachable from the refreshed main baseline.LOG + TN + CNfrom the exact source worktree; MOTR connected with MySQL/TCP to127.0.0.1:26001.127.0.0.1:26001were covered. The standard multi-CN endpoints127.0.0.1:16001,127.0.0.1:16002, and Proxy127.0.0.1:6001were not covered;:6001was already owned by a non-baseline Docker container and was deliberately not used.What Was Covered
go test ./pkg/sql/parsers/dialect/mysqlpassed on the exact latest main baseline.LAG(v) RESPECT NULLS OVER (...)parsed successfully.NTH_VALUE(v, 2) FROM FIRST OVER (...)parsed successfully.LEAD,FIRST_VALUE,LAST_VALUE, and combinedNTH_VALUE(..., 1) FROM FIRST RESPECT NULLScontrols parsed successfully.127.0.0.1:26001both passed:12statements,12successful,0failed.RESPECT NULLSandFROM FIRSTproduced the sameLAGandNTH_VALUEresults as their implicit defaults across partitions,NULLinput, and a full-partition window frame.respectremained valid as a non-reserved identifier.IGNORE NULLSandFROM LASTremained rejected with1064.CN1:16001,CN2:16002, and Proxy:6001.Findings
The latest main contains the parser grammar from PR #28064. Explicit
RESPECT NULLSandFROM FIRSTare accepted as MySQL-compatible no-op defaults, whileRESPECTremains non-reserved and the deliberately unsupported modifiers remain rejected.Large-data regression is not needed. This is a deterministic parser-grammar compatibility issue reached before row processing, planning, storage, network transfer, spill, or resource scaling.
MOTR / BVT Coverage
test/issue-28031-window-default-modifiers.90bf32c—test: add MOTR regression for #28031.suites/14_issue_regression/t/issue_28031_window_default_modifiers.testandsuites/14_issue_regression/r/issue_28031_window_default_modifiers.result.Final Conclusion
Fixed on refreshed
origin/mainbf63172c0691e917ed2613c2d3a2d3d76a7f682e. No large-data regression is required because the defect is data-size independent.fix(parser): support explicit default window modifiers (matrixorigin#…
fix(parser): support explicit default window modifiers (matrixorigin#…
fix(parser): support explicit default window modifiers (matrixorigin#…