Repository navigation
feat(sql): support APPROX_PERCENTILE WITHIN GROUP - #27864
mergify[bot] merged 1 commit into
Conversation
Signed-off-by: daviszhen <[email protected]>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Deep review on exact head 2c465e45078bfff8336cf6747571d7e508ea1b21.
Design gate: PASS for this revision. The public SQL contract is coherent: the legacy two-argument/window form remains unchanged; the ordered-set form has one percentile argument and one ordered expression; DESC is lowered to an exact 1-p complement before the unchanged executor. No aggregate-state or wire-format change is introduced.
Implementation review: parser/binder/explain/compile ownership is consistent, percentile validation preserves NULL/constant/type/range rules, and exact decimal complementation avoids floating-point drift at boundaries. Invalid arity, multiple ORDER BY items, dynamic/NULL percentile, and WITHIN GROUP plus OVER are covered. The extra work is compile-time only and bounded by the percentile literal length; the aggregation hot path is unchanged.
Validation: exact-head UT/SCA/coverage and both selected BVT jobs are green; func_aggr_ordered_set.test is included in the successful pessimistic BVT assignment. I found no correctness, compatibility, performance, resource-lifecycle, or unhappy-path blocker.
Merge Queue Status
This pull request spent 10 seconds in the queue, including 1 second running CI. Required conditions to merge
|
This PR implements the next ordered-set aggregate step proposed in matrixorigin#25110. - Adds `APPROX_PERCENTILE(p) WITHIN GROUP (ORDER BY value [ASC|DESC])`. - Commonizes ordered-set aggregate binder validation and lowering for `MEDIAN`, approximate percentile, and exact percentile functions. - Keeps the existing `APPROX_PERCENTILE(value, p)` syntax and its window behavior unchanged. - Implements DESC semantics by converting `p` to the exact decimal complement `1-p` before invoking the existing executor, without changing its aggregate configuration format. - Adds parser, planner, EXPLAIN, compiler, and BVT coverage plus a design note. Approved by: @XuPeng-SH
This PR implements the next ordered-set aggregate step proposed in matrixorigin#25110. - Adds `APPROX_PERCENTILE(p) WITHIN GROUP (ORDER BY value [ASC|DESC])`. - Commonizes ordered-set aggregate binder validation and lowering for `MEDIAN`, approximate percentile, and exact percentile functions. - Keeps the existing `APPROX_PERCENTILE(value, p)` syntax and its window behavior unchanged. - Implements DESC semantics by converting `p` to the exact decimal complement `1-p` before invoking the existing executor, without changing its aggregate configuration format. - Adds parser, planner, EXPLAIN, compiler, and BVT coverage plus a design note. Approved by: @XuPeng-SH
This PR implements the next ordered-set aggregate step proposed in matrixorigin#25110. - Adds `APPROX_PERCENTILE(p) WITHIN GROUP (ORDER BY value [ASC|DESC])`. - Commonizes ordered-set aggregate binder validation and lowering for `MEDIAN`, approximate percentile, and exact percentile functions. - Keeps the existing `APPROX_PERCENTILE(value, p)` syntax and its window behavior unchanged. - Implements DESC semantics by converting `p` to the exact decimal complement `1-p` before invoking the existing executor, without changing its aggregate configuration format. - Adds parser, planner, EXPLAIN, compiler, and BVT coverage plus a design note. Approved by: @XuPeng-SH
What type of PR is this?
Which issue(s) this PR fixes:
Related to #25110
What this PR does / why we need it:
This PR implements the next ordered-set aggregate step proposed in #25110.
APPROX_PERCENTILE(p) WITHIN GROUP (ORDER BY value [ASC|DESC]).MEDIAN, approximate percentile, and exact percentile functions.APPROX_PERCENTILE(value, p)syntax and its window behavior unchanged.pto the exact decimal complement1-pbefore invoking the existing executor, without changing its aggregate configuration format.Testing
Passed locally:
go test -mod=readonly ./pkg/sql/parsers/dialect/mysql ./pkg/sql/plan ./pkg/sql/plan/explain ./pkg/sql/compile -count=1go test -mod=readonly ./pkg/sql/colexec/aggexec -run ApproxPercentile -count=1go test -mod=readonly -race ./pkg/sql/plan -run TestBuildOrderedSetAggregates|TestBuildApproxPercentileWithinGroup -count=1go vet -mod=readonly ./pkg/sql/parsers/dialect/mysql ./pkg/sql/plan ./pkg/sql/plan/explain ./pkg/sql/compilegit diff --checkBVT cases and expected results were added; a distributed BVT service was not run locally.