jacktengg opened a new pull request, #67965:
URL: https://github.com/apache/doris/pull/67965
### What problem does this PR solve?
Issue Number: None
Related PR: None
Problem Summary: Float/double casts reject valid decimal endpoints and
values that round to them. Adding 0.5 before truncation also changes exactly
representable large integers, and Decimal256 loses intermediate precision by
narrowing long double back to double. For example, casting DOUBLE
4503599627370497 to DECIMAL(16,0) produces 4503599627370498, and casting DOUBLE
9007199254740991 to DECIMAL(39,1) produces 9007199254740990.4.
Share the DecimalV2/V3 conversion, round explicitly, preserve Decimal256's
intermediate precision with integer limbs, and check inclusive bounds in
integer arithmetic. Also check the original integer part so high-scale
multiplication cannot round an overflowing input such as 10 into DECIMAL(38,37)
back into range. Use decimal parsing to derive existing unit-test expectations
independently of floating-to-integer casts. Add focused unit and regression
coverage for signed endpoints, rounding, high-scale overflow, Decimal256, and
strict/non-strict casts.
### Release note
Fix valid floating-point decimal casts being rejected, incorrect rounding of
large integers, and loss of Decimal256 intermediate precision. Preserve
overflow errors in strict mode and NULL results in non-strict mode.
### Check List (For Author)
- Test: Unit Test / Regression test / Manual test
- ASAN BE build: ./build.sh --be -j32
- 21 targeted FunctionCastToDecimalTest unit tests passed via
run-be-ut.sh.
- 18 regression suites passed in cast_double_to_decimal and
function_p2/cast/to_decimal/from_float.
- Regression output generated by run-regression-test.sh and verified by
a subsequent comparison run.
- clang-format 16 and build hygiene checks passed.
- clang-tidy changed-line checks passed using the toolchain resource
directory and a temporary VFS overlay omitting an existing unmatched NOLINTEND
comment in core/types.h; that source file is unchanged.
- Behavior changed: Yes, correct decimal boundary acceptance, rounding, and
Decimal256 precision.
- Does this need documentation: No
### What problem does this PR solve?
Issue Number: close #xxx
Related PR: #xxx
Problem Summary:
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### 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]