Skip to content

branch-4.2: [fix](be) Fix CONV results for negative string inputs #68984 - #70377

Open
github-actions[bot] wants to merge 1 commit into
branch-4.2from
auto-pick-68984-branch-4.2
Open

github-actions[bot] wants to merge 1 commit into
branch-4.2from
auto-pick-68984-branch-4.2

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Cherry-picked from #68984

### What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary: CONV('-10', 10, 10) returned 18446744073709551615 while
CONV(-10, 10, 10) returned 18446744073709551606. Converting the string
to
signed output with CONV('-10', 10, -10) or CONV('-10', 2, -10) likewise
returned -1 instead of -10 or -2.

The base-aware string parser added one to UINT64_MAX when it encountered
a negative sign, wrapping the unsigned magnitude limit to zero and
incorrectly reporting overflow. Expand the negative magnitude limit only
for signed integer types, using unsigned arithmetic; keep the full
unsigned magnitude limit when parsing negative strings as uint64_t.

Negative destination bases continue to select signed output, and allowed
base magnitudes remain [2, 36]. Add unsigned parser boundary tests and
CONV
coverage for negative string and integer inputs, signed and unsigned
output, 64-bit limits and overflow, NULLs, all TINYINT base values, all
eight constant/column argument combinations, and constant folding.
Generate the regression output through the standard regression script.

The reported six-expression query now returns
18446744073709551606, 18446744073709551606, -10, -10, -2, -2.

### Release note

Fix incorrect CONV results for negative string inputs, including signed
output selected by a negative destination base.

### Check List (For Author)

- Test:
    - ASAN BE build: ./build.sh --be -j32
- Unit Test: ./run-be-ut.sh --run
--filter='MathFunctionTest.conv*:StringToIntWithBase.*' -j32 (10 tests
passed)
- Regression test: ./run-regression-test.sh --run -d
query_p0/sql_functions/math_functions -s test_conv_negative_base_range
-forceGenOut
- Regression test: ./run-regression-test.sh --run -d
query_p0/sql_functions/math_functions -s
test_conv,test_conv_negative_base_range (2 suites passed)
- Manual test: verified the reported six-expression SQL on the rebuilt
worktree cluster
- clang-format 16, clang-tidy on changed lines, build hygiene, and git
diff checks passed
- Behavior changed: Yes, correct negative string conversion results
while preserving existing negative base support
- Does this need documentation: No, this is a bug fix with existing base
semantics preserved
### Check List (For Reviewer who merge this PR)

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR
should merge into -->
@github-actions
github-actions Bot requested a review from yiguolei as a code owner November 8, 2026 12:51
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@hello-stephen

Copy link
Copy Markdown
Contributor

run buildall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants