Skip to content

fix(window): support prepared ROWS frame bounds - #26094

Merged
XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25993-prepared-window-frame
Jul 24, 2026
Merged

XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
LeftHandCold:fix/issue-25993-prepared-window-frame

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #25993

What this PR does / why we need it:

Prepared statements could not parse ? PRECEDING/FOLLOWING ROWS bounds, and window planning previously folded finite bounds before execution. This change preserves typed parameter expressions, visits and renumbers all window expressions without double-processing shared partition aliases, transports parameters unchanged, and materializes immutable operator-local ROWS frames once per Prepare generation. Dynamic RANGE and interval bounds remain explicitly unsupported.

The runtime path rejects missing, NULL, negative, fractional, overflow, and failed-conversion bounds before processing rows. Reset and Free clear runtime frames, while cached plan expressions remain unchanged.

Tested with:

./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s ./pkg/sql/parsers/dialect/mysql ./pkg/sql/parsers/tree ./pkg/sql/plan ./pkg/sql/colexec/window ./pkg/vm/process

./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run "TestWindow(Prepare|Reset).*FrameBound" -count=1 -timeout=240s ./pkg/sql/colexec/window

Configured go build and go vet passed for all modified packages. The distributed SQL fixture is included for CI; local mo-tester was unavailable.

@LeftHandCold
LeftHandCold requested a review from a user July 23, 2026 07:59
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@mergify mergify Bot added kind/bug Something isn't working kind/test-ci labels Jul 23, 2026
@matrix-meow matrix-meow added the size/XXL Denotes a PR that changes 2000+ lines label Jul 23, 2026

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deep-reviewed the exact latest head. The parser/binder/prepare visitor/runtime closure is complete: ROWS markers remain typed plan expressions, alias-shared window expressions are visited once, cached operators materialize immutable per-Prepare frames from the current parameter vector, non-cached executions deep-copy before parameter replacement, remote processes preserve parameter bytes/binary flags, and Reset/Free close the generation boundary. Invalid NULL/negative/fractional/overflow/missing values fail before row processing. Generated parser output is byte-for-byte reproducible with zero new conflicts. Fresh affected-package tests, focused race x10, full window-package race, build, vet, diff checks, and the merge-tree against current main all pass; all PR CI checks are green. No blocking correctness, performance, or lifecycle issue found.

@XuPeng-SH
XuPeng-SH merged commit f5753b4 into matrixorigin:main Jul 24, 2026
4 of 5 checks passed
@mergify mergify Bot removed the queued label Jul 24, 2026
mergify Bot pushed a commit that referenced this pull request Jul 28, 2026
Prepared SET was rejected because the DCL carrier did not retain ordered parameter metadata and SET expression evaluation lost prepared context when it synthesized internal SELECT statements.

This change collects parameters and schemas from retained SET expressions plus transient scalar-subquery plans, preserves global parser ordinals across multiple assignments, explicitly propagates prepared mode through initial and retry planning, bypasses invalid empty-SQL plan-cache keys for SET-derived AST inputs, and preserves decimal result binding. Supplemental aggregate/window traversal is idempotent with the generic visitor work in #26042 and #26094.

The saved prepared AST and DCL plan remain immutable during EXECUTE. Text and binary repeated execution, multiple markers, NULL replacement, scalar/nested subqueries, aggregate/window fields, decimal expressions, cache isolation, and retry rebuilding are covered.

Tested with:

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plan ./pkg/frontend`

`./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run "TestPreparedSet|TestSetExpression|TestPreparedSetExpression" -count=1 -timeout=240s ./pkg/frontend`

Configured `go build` and `go vet` passed for planner/frontend. The distributed SQL fixture is included for CI; local `mo-tester` was unavailable.

Approved by: @XuPeng-SH, @heni02
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25993

## What this PR does / why we need it:

Prepared statements could not parse `? PRECEDING/FOLLOWING` ROWS bounds,
and window planning previously folded finite bounds before execution.
This change preserves typed parameter expressions, visits and renumbers
all window expressions without double-processing shared partition
aliases, transports parameters unchanged, and materializes immutable
operator-local ROWS frames once per `Prepare` generation. Dynamic RANGE
and interval bounds remain explicitly unsupported.

The runtime path rejects missing, NULL, negative, fractional, overflow,
and failed-conversion bounds before processing rows. `Reset` and `Free`
clear runtime frames, while cached plan expressions remain unchanged.

Tested with:

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s
./pkg/sql/parsers/dialect/mysql ./pkg/sql/parsers/tree ./pkg/sql/plan
./pkg/sql/colexec/window ./pkg/vm/process`

`./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run
"TestWindow(Prepare|Reset).*FrameBound" -count=1 -timeout=240s
./pkg/sql/colexec/window`

Configured `go build` and `go vet` passed for all modified packages. The
distributed SQL fixture is included for CI; local `mo-tester` was
unavailable.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Prepared SET was rejected because the DCL carrier did not retain ordered parameter metadata and SET expression evaluation lost prepared context when it synthesized internal SELECT statements.

This change collects parameters and schemas from retained SET expressions plus transient scalar-subquery plans, preserves global parser ordinals across multiple assignments, explicitly propagates prepared mode through initial and retry planning, bypasses invalid empty-SQL plan-cache keys for SET-derived AST inputs, and preserves decimal result binding. Supplemental aggregate/window traversal is idempotent with the generic visitor work in matrixorigin#26042 and matrixorigin#26094.

The saved prepared AST and DCL plan remain immutable during EXECUTE. Text and binary repeated execution, multiple markers, NULL replacement, scalar/nested subqueries, aggregate/window fields, decimal expressions, cache isolation, and retry rebuilding are covered.

Tested with:

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plan ./pkg/frontend`

`./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run "TestPreparedSet|TestSetExpression|TestPreparedSetExpression" -count=1 -timeout=240s ./pkg/frontend`

Configured `go build` and `go vet` passed for planner/frontend. The distributed SQL fixture is included for CI; local `mo-tester` was unavailable.

Approved by: @XuPeng-SH, @heni02
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25993

## What this PR does / why we need it:

Prepared statements could not parse `? PRECEDING/FOLLOWING` ROWS bounds,
and window planning previously folded finite bounds before execution.
This change preserves typed parameter expressions, visits and renumbers
all window expressions without double-processing shared partition
aliases, transports parameters unchanged, and materializes immutable
operator-local ROWS frames once per `Prepare` generation. Dynamic RANGE
and interval bounds remain explicitly unsupported.

The runtime path rejects missing, NULL, negative, fractional, overflow,
and failed-conversion bounds before processing rows. `Reset` and `Free`
clear runtime frames, while cached plan expressions remain unchanged.

Tested with:

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s
./pkg/sql/parsers/dialect/mysql ./pkg/sql/parsers/tree ./pkg/sql/plan
./pkg/sql/colexec/window ./pkg/vm/process`

`./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run
"TestWindow(Prepare|Reset).*FrameBound" -count=1 -timeout=240s
./pkg/sql/colexec/window`

Configured `go build` and `go vet` passed for all modified packages. The
distributed SQL fixture is included for CI; local `mo-tester` was
unavailable.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Prepared SET was rejected because the DCL carrier did not retain ordered parameter metadata and SET expression evaluation lost prepared context when it synthesized internal SELECT statements.

This change collects parameters and schemas from retained SET expressions plus transient scalar-subquery plans, preserves global parser ordinals across multiple assignments, explicitly propagates prepared mode through initial and retry planning, bypasses invalid empty-SQL plan-cache keys for SET-derived AST inputs, and preserves decimal result binding. Supplemental aggregate/window traversal is idempotent with the generic visitor work in matrixorigin#26042 and matrixorigin#26094.

The saved prepared AST and DCL plan remain immutable during EXECUTE. Text and binary repeated execution, multiple markers, NULL replacement, scalar/nested subqueries, aggregate/window fields, decimal expressions, cache isolation, and retry rebuilding are covered.

Tested with:

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plan ./pkg/frontend`

`./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run "TestPreparedSet|TestSetExpression|TestPreparedSetExpression" -count=1 -timeout=240s ./pkg/frontend`

Configured `go build` and `go vet` passed for planner/frontend. The distributed SQL fixture is included for CI; local `mo-tester` was unavailable.

Approved by: @XuPeng-SH, @heni02
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#25993

## What this PR does / why we need it:

Prepared statements could not parse `? PRECEDING/FOLLOWING` ROWS bounds,
and window planning previously folded finite bounds before execution.
This change preserves typed parameter expressions, visits and renumbers
all window expressions without double-processing shared partition
aliases, transports parameters unchanged, and materializes immutable
operator-local ROWS frames once per `Prepare` generation. Dynamic RANGE
and interval bounds remain explicitly unsupported.

The runtime path rejects missing, NULL, negative, fractional, overflow,
and failed-conversion bounds before processing rows. `Reset` and `Free`
clear runtime frames, while cached plan expressions remain unchanged.

Tested with:

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=120s
./pkg/sql/parsers/dialect/mysql ./pkg/sql/parsers/tree ./pkg/sql/plan
./pkg/sql/colexec/window ./pkg/vm/process`

`./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run
"TestWindow(Prepare|Reset).*FrameBound" -count=1 -timeout=240s
./pkg/sql/colexec/window`

Configured `go build` and `go vet` passed for all modified packages. The
distributed SQL fixture is included for CI; local `mo-tester` was
unavailable.

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
Prepared SET was rejected because the DCL carrier did not retain ordered parameter metadata and SET expression evaluation lost prepared context when it synthesized internal SELECT statements.

This change collects parameters and schemas from retained SET expressions plus transient scalar-subquery plans, preserves global parser ordinals across multiple assignments, explicitly propagates prepared mode through initial and retry planning, bypasses invalid empty-SQL plan-cache keys for SET-derived AST inputs, and preserves decimal result binding. Supplemental aggregate/window traversal is idempotent with the generic visitor work in matrixorigin#26042 and matrixorigin#26094.

The saved prepared AST and DCL plan remain immutable during EXECUTE. Text and binary repeated execution, multiple markers, NULL replacement, scalar/nested subqueries, aggregate/window fields, decimal expressions, cache isolation, and retry rebuilding are covered.

Tested with:

`./.agents/skills/mo-dev/scripts/mo-cgo-test -count=1 -timeout=180s ./pkg/sql/plan ./pkg/frontend`

`./.agents/skills/mo-dev/scripts/mo-cgo-test -race -run "TestPreparedSet|TestSetExpression|TestPreparedSetExpression" -count=1 -timeout=240s ./pkg/frontend`

Configured `go build` and `go vet` passed for planner/frontend. The distributed SQL fixture is included for CI; local `mo-tester` was unavailable.

Approved by: @XuPeng-SH, @heni02

This branch was previously deployed

1 inactive deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working kind/test-ci size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants