mihaibudiu opened a new pull request, #4845:
URL: https://github.com/apache/calcite/pull/4845

   ## Jira Link
   
   https://issues.apache.org/jira/browse/CALCITE-7443
   
   ## Changes Proposed
   
   This PR changes all arithmetic on values of type INTERVAL to use checked 
arithmetic. 
   
   Currently, using the default conformance, Calcite's arithmetic obeys the 
Java rules, i.e., overflow is just wrap-around. There is a conformance flag 
which allows you to change this behavior; checked arithmetic will throw on 
overflow (at runtime).
   
   Values such as intervals are encoded into long/integer values, and 
arithmetic on intervals is compiled into suitably scaled computations in Java. 
However, I can argue that there is no reason for interval arithmetic to 
wrap-around; in fact, if it does, it can produce very surprising results, since 
the encoding of intervals into integers is not part of any spec (it is an 
implementation detail).
   
   We already had a visitor to convert unchecked arithmetic into checked 
arithmetic. Previously the visitor was only invoked when the conformance 
required checked arithmetic. Now the visitor is always invoked, and it performs 
the following rewrites:
   - any operation that has an operand of type interval and a result of type 
interval is rewritten to use checked arithmetic
   - other arithmetic operations are rewritten to be checked only if 
conformance requires it, keeping the previous behavior


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

Reply via email to