Repository navigation
feat: support prepared percentile expressions - #29130
Conversation
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? |
50711c8 to
861165e
Compare
XuPeng-SH
left a comment
There was a problem hiding this comment.
Request changes for exact head 45cf5402b312d26ef24c6dfee50f2a5ae18f55bb.
[P2] Preserve DECIMAL percentile precision before range validation.
pkg/sql/plan/base_binder.go:5020-5031 still wraps prepared CAST(? AS DECIMAL(19,18)) in FLOAT64. With ordered values {10,20}, percentile 0.500000000000000001 becomes 0.5), so PERCENTILE_DISCselects 10 instead of 20. Likewise1.000000000000000001becomes1.0` and is accepted because the range check sees the already-rounded value.
Preserve supported numeric expression types and apply FLOAT64 normalization only where needed for untyped/text markers. Add prepared decimal precision and out-of-range regressions. No additional P0–P2 findings were found in repeated execution, aggregate/window cleanup, scalar/vector handling, serialization, or non-prepared paths.
XuPeng-SH
left a comment
There was a problem hiding this comment.
APPROVE — reviewed exact head 6d91ed4. The previous DECIMAL percentile precision issue is fixed: prepared DECIMAL expressions retain exact configuration text, precise discrete ranking works, and out-of-range values are rejected. Prepared/repeated execution, group/window reset, scalar/vector, serialization and cleanup paths show no actionable P0–P2 findings. Exact-head UT/race, SCA and BVT passed; upgrade and combined prepared-window parity evidence remain gaps.
Merge Queue Status
This pull request spent 28 minutes 26 seconds in the queue, with no time running CI. ReasonThe pull request can't be updated
HintYou should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
Which issue(s) this PR fixes:
issue #25110
What this PR does / why we need it:
Extends percentile configuration to accept execution-invariant prepared
expressions such as
? / 100.0forAPPROX_PERCENTILE,PERCENTILE_CONT, andPERCENTILE_DISC.numeric casts.
functions, and nonnumeric casts.
FLOAT64before aggregateoverload selection and evaluates it as fixed configuration for each
EXECUTE.the cached prepared plan.
existing preflight error path, including queries with empty input.
Validation:
go test ./pkg/sql/plan -count=1go test ./pkg/sql/compile -count=1valid-error-valid prepared reuse, and invalid empty-input preflight. The BVT
file was not executed locally and is left for CI validation.