Skip to content

fix(function): reject out-of-range power results - #25464

Merged
XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
ck89119:issue-25308-main
Jul 6, 2026
Merged

XuPeng-SH merged 4 commits into
matrixorigin:mainfrom
ck89119:issue-25308-main

Conversation

@ck89119

@ck89119 ck89119 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

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

Which issue(s) this PR fixes:

Fixes #25308

What this PR does / why we need it:

Reject non-finite results from POW and POWER with an out-of-range error instead of returning NaN or infinity.

The root cause was that the shared Power implementation appended the result of Go's math.Pow without checking for NaN or infinity. The implementation now returns ErrOutOfRange for non-finite results while preserving finite values and NULL handling.

Regression coverage includes negative bases with fractional exponents, zero raised to a negative exponent, mixed valid/invalid vectors, and distributed SQL cases for both aliases.

Validation:

  • go test -count=1 -timeout 120s ./pkg/sql/plan/function
  • go test -race -count=1 -timeout 120s -run '^TestPower(OutOfRange)?$' ./pkg/sql/plan/function
  • go vet ./pkg/sql/plan/function
  • go build ./pkg/sql/plan/function
  • mo-tester: 53/53 statements passed for func_math_power.test

@ck89119
ck89119 requested a review from aunjgr as a code owner July 6, 2026 06:37
@ck89119
ck89119 requested a review from a user July 6, 2026 06:37
@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 →

@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.

I did not find a blocker in this fix.

The change now rejects non-finite POW/POWER results as out-of-range while preserving normal finite values, NULL propagation, and alias behavior. The added select-list guard also matches the existing FunctionSelectList semantics, so filtered rows no longer evaluate the invalid branch.

@XuPeng-SH
XuPeng-SH merged commit a5cb217 into matrixorigin:main Jul 6, 2026
23 checks passed
@ck89119
ck89119 deleted the issue-25308-main branch July 7, 2026 02:37
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
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25308

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

Reject non-finite results from `POW` and `POWER` with an out-of-range
error instead of returning `NaN` or infinity.

The root cause was that the shared `Power` implementation appended the
result of Go's `math.Pow` without checking for `NaN` or infinity. The
implementation now returns `ErrOutOfRange` for non-finite results while
preserving finite values and NULL handling.

Regression coverage includes negative bases with fractional exponents,
zero raised to a negative exponent, mixed valid/invalid vectors, and
distributed SQL cases for both aliases.

Validation:

- `go test -count=1 -timeout 120s ./pkg/sql/plan/function`
- `go test -race -count=1 -timeout 120s -run '^TestPower(OutOfRange)?$'
./pkg/sql/plan/function`
- `go vet ./pkg/sql/plan/function`
- `go build ./pkg/sql/plan/function`
- `mo-tester`: 53/53 statements passed for `func_math_power.test`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25308

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

Reject non-finite results from `POW` and `POWER` with an out-of-range
error instead of returning `NaN` or infinity.

The root cause was that the shared `Power` implementation appended the
result of Go's `math.Pow` without checking for `NaN` or infinity. The
implementation now returns `ErrOutOfRange` for non-finite results while
preserving finite values and NULL handling.

Regression coverage includes negative bases with fractional exponents,
zero raised to a negative exponent, mixed valid/invalid vectors, and
distributed SQL cases for both aliases.

Validation:

- `go test -count=1 -timeout 120s ./pkg/sql/plan/function`
- `go test -race -count=1 -timeout 120s -run '^TestPower(OutOfRange)?$'
./pkg/sql/plan/function`
- `go vet ./pkg/sql/plan/function`
- `go build ./pkg/sql/plan/function`
- `mo-tester`: 53/53 statements passed for `func_math_power.test`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
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
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#25308

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

Reject non-finite results from `POW` and `POWER` with an out-of-range
error instead of returning `NaN` or infinity.

The root cause was that the shared `Power` implementation appended the
result of Go's `math.Pow` without checking for `NaN` or infinity. The
implementation now returns `ErrOutOfRange` for non-finite results while
preserving finite values and NULL handling.

Regression coverage includes negative bases with fractional exponents,
zero raised to a negative exponent, mixed valid/invalid vectors, and
distributed SQL cases for both aliases.

Validation:

- `go test -count=1 -timeout 120s ./pkg/sql/plan/function`
- `go test -race -count=1 -timeout 120s -run '^TestPower(OutOfRange)?$'
./pkg/sql/plan/function`
- `go vet ./pkg/sql/plan/function`
- `go build ./pkg/sql/plan/function`
- `mo-tester`: 53/53 statements passed for `func_math_power.test`

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

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 size/S Denotes a PR that changes [10,99] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: POW with negative base and fractional exponent returns NaN instead of MySQL error

3 participants