Skip to content

fix: preserve NULL VARCHAR values in FLOOR - #28510

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
Lundomn:codex/fix-floor-varchar-null
Sep 9, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
Lundomn:codex/fix-floor-varchar-null

Conversation

@Lundomn

@Lundomn Lundomn commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Closes #28486.

FloorStr appended a NULL result but then continued to parse that row empty VARCHAR payload. Reuse the existing unary string-to-fixed template so input NULLs and CASE selection masks are propagated before parsing; non-NULL parsing and error behavior stay unchanged.

Compatibility and boundaries

  • Typed NULL constants, mixed vectors with first/middle/last NULLs, all-NULL vectors, and masked rows preserve length and row correspondence.
  • Invalid unmasked strings still return the original parse error.
  • Constant decimal places remain supported; non-constant or wrongly typed decimal places remain rejected.
  • The BVT covers typed NULL, CASE, SQL PREPARE, and CTAS. This does not change [Compatibility]: exact math functions misparse character numeric operands #28487 broader character-to-number compatibility behavior.

Tests

  • mo-cgo-test focused FloorStr tests: pass.
  • mo-cgo-test owning package with coverage: pass; FloorStr is 100% covered.
  • go vet for pkg/sql/plan/function with repository CGo environment: pass.
  • Native mo-tester BVT: two consecutive passes, 16/16 statements each.
  • git diff --check origin/main...HEAD: pass.

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

Deep review of exact head c0b5664 against cd04bb4. No confirmed blocker.

Reviewed all four changed files and traced FloorStr through the exact-head unary template, result-vector preparation, selection mask and VARCHAR overload. The fix skips NULL payloads before parsing and preserves one result per input row, including constant/all-NULL and mixed vectors. Unmasked malformed/empty strings still return the existing ParseFloat error; finite values, signed boundaries and NaN/Inf retain the same scalar parser/floor implementation. Overload selection, DOUBLE result type and numeric overloads are unchanged. Constant inputs now avoid repeated parsing; no new shared state, wait or resource owner is introduced. This is an ordinary focused bug fix, not a feature requiring a separate design phase.

The focused UT checks result type, length, NULL bitmap, row correspondence, constants, masks and invalid decimal-place arguments. The public BVT checks typed NULL, mixed vectors, CASE, all-NULL input, PREPARE and CTAS with database teardown. Reused the author's recorded focused/owning-package coverage and two consecutive native BVT passes, plus successful exact-head CI run 34324693477 (UT, SCA, coverage and multi-CN BVT); no additional local native run is claimed. The broader character-to-number compatibility issue #28487 is intentionally unchanged.

@mergify

mergify Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

Closes matrixorigin#28486.

FloorStr appended a NULL result but then continued to parse that row
empty VARCHAR payload. Reuse the existing unary string-to-fixed template
so input NULLs and CASE selection masks are propagated before parsing;
non-NULL parsing and error behavior stay unchanged.

## Compatibility and boundaries

- Typed NULL constants, mixed vectors with first/middle/last NULLs,
all-NULL vectors, and masked rows preserve length and row
correspondence.
- Invalid unmasked strings still return the original parse error.
- Constant decimal places remain supported; non-constant or wrongly
typed decimal places remain rejected.
- The BVT covers typed NULL, CASE, SQL PREPARE, and CTAS. This does not
change matrixorigin#28487 broader character-to-number compatibility behavior.

## Tests

- mo-cgo-test focused FloorStr tests: pass.
- mo-cgo-test owning package with coverage: pass; FloorStr is 100%
covered.
- go vet for pkg/sql/plan/function with repository CGo environment:
pass.
- Native mo-tester BVT: two consecutive passes, 16/16 statements each.
- git diff --check origin/main...HEAD: pass.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

Closes matrixorigin#28486.

FloorStr appended a NULL result but then continued to parse that row
empty VARCHAR payload. Reuse the existing unary string-to-fixed template
so input NULLs and CASE selection masks are propagated before parsing;
non-NULL parsing and error behavior stay unchanged.

## Compatibility and boundaries

- Typed NULL constants, mixed vectors with first/middle/last NULLs,
all-NULL vectors, and masked rows preserve length and row
correspondence.
- Invalid unmasked strings still return the original parse error.
- Constant decimal places remain supported; non-constant or wrongly
typed decimal places remain rejected.
- The BVT covers typed NULL, CASE, SQL PREPARE, and CTAS. This does not
change matrixorigin#28487 broader character-to-number compatibility behavior.

## Tests

- mo-cgo-test focused FloorStr tests: pass.
- mo-cgo-test owning package with coverage: pass; FloorStr is 100%
covered.
- go vet for pkg/sql/plan/function with repository CGo environment:
pass.
- Native mo-tester BVT: two consecutive passes, 16/16 statements each.
- git diff --check origin/main...HEAD: pass.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## Summary

Closes matrixorigin#28486.

FloorStr appended a NULL result but then continued to parse that row
empty VARCHAR payload. Reuse the existing unary string-to-fixed template
so input NULLs and CASE selection masks are propagated before parsing;
non-NULL parsing and error behavior stay unchanged.

## Compatibility and boundaries

- Typed NULL constants, mixed vectors with first/middle/last NULLs,
all-NULL vectors, and masked rows preserve length and row
correspondence.
- Invalid unmasked strings still return the original parse error.
- Constant decimal places remain supported; non-constant or wrongly
typed decimal places remain rejected.
- The BVT covers typed NULL, CASE, SQL PREPARE, and CTAS. This does not
change matrixorigin#28487 broader character-to-number compatibility behavior.

## Tests

- mo-cgo-test focused FloorStr tests: pass.
- mo-cgo-test owning package with coverage: pass; FloorStr is 100%
covered.
- go vet for pkg/sql/plan/function with repository CGo environment:
pass.
- Native mo-tester BVT: two consecutive passes, 16/16 statements each.
- git diff --check origin/main...HEAD: pass.

---------

Co-authored-by: XuPeng-SH <[email protected]>

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

size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: FLOOR parses NULL VARCHAR rows as empty strings

3 participants