jacktengg opened a new pull request, #68397:
URL: https://github.com/apache/doris/pull/68397
Issue Number: None
Related PR: None
Problem Summary: format_round(CAST('1.44' AS DECIMAL(38, 2)), 20) returns
1.00000000000000000044 instead of 1.44000000000000000000. The decimal formatter
uses a 32-bit power-of-ten helper to expand the fraction and narrows the
fraction to int when rounding and rendering it. This also corrupts existing
high-scale fractions. The DECIMALV2 caller additionally discards all but three
fractional digits.
Round with full-width integer arithmetic and append trailing zeroes in the
output buffer instead of scaling the fraction. Pass the complete DECIMALV2
fraction. Cover decimal widths, constant and column arguments, NULLs, negative
values, rounding carries, and the 1024-place boundary. Regenerate the two
existing incorrect format_round expectations and verify money_format retains
exact two-place rounding.
Fix incorrect format_round results for high-precision decimals and preserve
all fractional digits of DECIMALV2 inputs before rounding.
- Test:
- ASAN BE build via ./build.sh --be -j48
- Unit Test: 7 tests passed via ./run-be-ut.sh --run
--filter='FormatRoundTest.*:function_money_format_test.*' -j48
- Regression test: test_format_round, test_format_round_decimal, and
test_money_format passed
- Manual test: original SQL reproduced before the fix and returned exact
decimal results after it; 59 generated SQL output rows checked against Python
Decimal ROUND_HALF_UP
- clang-format v16 and build hygiene passed
- clang-tidy attempted; blocked by the pre-existing unmatched NOLINTEND
in be/src/core/types.h:576
- Behavior changed: Yes, decimal formatting preserves the correct value and
requested fractional digits
- 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]