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

   [fix](function) Report overflow in decimal ceil and floor
   
   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: #68251
   
   Problem Summary: Decimal CEIL/FLOOR silently returned zero when both the 
rounding divisor and the result multiplier exceeded the native Decimal range. 
For example, `CEIL(NULLABLE(0.123456789), NULLABLE(-1))` returned zero instead 
of reporting that the rounded value cannot fit in the existing result type. 
Root cause: the saturated-factor branch discarded nonzero directed-rounding 
results. This change reports arithmetic overflow for positive CEIL and negative 
FLOOR in that branch, with a hint to cast the input to a Decimal with 
sufficient precision. Zero results and return types remain unchanged.
   
   ### Release note
   
   Decimal CEIL/FLOOR now report arithmetic overflow instead of silently 
returning zero when a nonzero directed-rounding result requires an 
unrepresentable result multiplier.
   
   ### Check List (For Author)
   
   - Test:
       - [x] Unit Test: ASAN `RoundFunctionTest.decimal_rounding_overflow` 
passed.
       - [ ] The broader `RoundFunctionTest.*` run still has two legacy 
expectations for values that now correctly report overflow; those cases need 
follow-up test updates.
   - Behavior changed:
       - [x] Yes. Previously incorrect zero results now produce an arithmetic 
overflow error; return types are unchanged.
   - Does this need documentation?
       - [x] Yes. CEIL/FLOOR overflow behavior and casting guidance should be 
documented; documentation follow-up is pending.
   
   ### Check List (For Reviewer who merge this PR)
   
   - [ ] Confirm the release note
   - [ ] Confirm test cases
   - [ ] Confirm document
   - [ ] Add branch pick label
   


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