jacktengg opened a new pull request, #68984:
URL: https://github.com/apache/doris/pull/68984

   [fix](be) Fix CONV results for negative string inputs
   
   ### 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 -->
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to