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

   ### What problem does this PR solve?
   
   Issue Number: N/A
   
   Related PR: N/A
   
   Problem Summary:
   `quarters_add` / `quarters_sub` uses the i32 middle value when converting 
quarters to months, and the oversized INT parameter may have an integer 
backturn, bypassing the subsequent date range check and returning the wrong 
date.
   
   This repair includes:
   
   1. **BE quarter addition and subtraction**: Use Int64 to receive the 
quarterly offset and calculate the number of months to avoid overflow when 
multiplying by 3, and also avoid `quarters_sub` to narrowing back to i32 when 
calling addition after negative INT_MIN. Four date types share this repair, and 
the real bias is transferred to the existing date range for inspection and 
processing.
   
   2. **FE quarter function calculation**: complete the `quarters_add` of 
TIMESTAMP_NS, using long multiplication; four date types `quarters_sub` 
directly calculate `-3L * quarter `, avoid losing in i32 first. The original 
long addition of DATE/DATETIME/TIMESTAMPTZ and the return mechanism after the 
failure of constant folding remain unchanged.
   
   3. **Error message**: The offset parameter in the date cross-bound error 
uses Int64 to avoid truncating the number of months again when the error is 
reported.
   
   ### Release note
   
   Fix quarters_add and quarters_sub returning incorrect dates for excessively 
large quarter intervals; these inputs now report date-range errors.
   


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