Repository navigation
feat: implement CUME_DIST window function - #23762
Merged
Merged
Conversation
Implement MySQL-compatible CUME_DIST() window function that returns the cumulative distribution of a value within a partition. Formula: (rows with values <= current row) / (total rows in partition) Return type: DOUBLE, range (0, 1] Changes: - Parser: Add CUME_DIST keyword and syntax rule - Executor: Implement cumeDistWindowExec with float64 return type - Function: Register CUME_DIST as WIN_ORDER function - Tests: Add SQL test cases Reference: https://dev.mysql.com/doc/refman/8.4/en/window-function-descriptions.html#function_cume-dist
ck89119
requested review from
aunjgr,
iamlinjunhong and
ouyuanning
as code owners
February 25, 2026 09:44
ghost
approved these changes
Feb 26, 2026
ouyuanning
approved these changes
Feb 26, 2026
iamlinjunhong
approved these changes
Feb 26, 2026
Contributor
Merge Queue StatusRule:
This pull request spent 9 seconds in the queue, with no time running CI. Required conditions to merge
|
1 of 7 tasks
mergify Bot
pushed a commit
that referenced
this pull request
Apr 28, 2026
- #23841 `ELT()` MySQL compatibility - #23639 `AES_ENCRYPT()` / `AES_DECRYPT()` - #23762 `CUME_DIST()` window function - #23764 `PERCENT_RANK()` window function ### Notes on adaptation * `CUME_DIST` and `PERCENT_RANK` did not cherry-pick cleanly because main's `pkg/sql/colexec/aggexec` layer has been refactored substantially relative to 3.0-dev (different signatures for `initAggResultWithFixedTypeResult`, `marshalToBytes`, `unmarshalFromBytes`, plus new `SaveIntermediateResult*` / `UnmarshalFromReader` interface methods and an `i64Slice` type). These two executors were rewritten to follow 3.0-dev's existing `singleWindowExec` pattern (`[][]int64` groups, 3-return `marshalToBytes`, 2-arg `unmarshalFromBytes`, no streaming serialization). Algorithms match the originals exactly. * The ELT cherry-pick brought in a copy of `func_binary_test.go` from main containing tests for `TimeFormat` / `TimestampDiffDateString` / etc. that don't exist on 3.0-dev. Those test blocks were removed; the ELT-specific tests at the end of the file are preserved. Also added the `ELT` function id and overload registration that the cherry-pick didn't include. ### Verification ``` go build ./... go test -tags matrixone_test ./pkg/sql/colexec/aggexec/ \ ./pkg/sql/colexec/window/ \ ./pkg/sql/parsers/... \ ./pkg/sql/plan/function/ ``` all pass. Fixes #24185 Approved by: @heni02, @iamlinjunhong, @ouyuanning, @aunjgr, @XuPeng-SH
fengttt
pushed a commit
to fengttt/matrixone
that referenced
this pull request
May 7, 2026
Implement MySQL-compatible CUME_DIST() window function. CUME_DIST() returns the cumulative distribution of a value within a partition. **Formula**: (rows with values <= current row) / (total rows in partition) **Return type**: DOUBLE, range (0, 1] Approved by: @heni02, @ouyuanning, @iamlinjunhong
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
Which issue(s) this PR fixes:
issue #23011
What this PR does / why we need it:
Implement MySQL-compatible CUME_DIST() window function.
CUME_DIST() returns the cumulative distribution of a value within a partition.
Formula: (rows with values <= current row) / (total rows in partition)
Return type: DOUBLE, range (0, 1]
Changes
Parser
Executor
cumeDistWindowExecstructure with float64 return typeflushCumeDist()algorithmFunction Registration
Tests
Example Usage
Reference
https://dev.mysql.com/doc/refman/8.4/en/window-function-descriptions.html#function_cume-dist